#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 2;
int ar[N], ar1[N];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, i, j, k, l, r;
  long long sum;
  cin >> n >> sum;
  if (sum < 1ll * n * (n + 1) / 2) {
    cout << -1;
    return 0;
  }
  for (i = 1; i <= n; i++) {
    ar[i] = i;
    ar1[i] = i;
  }
  l = 1;
  r = n;
  sum -= 1ll * n * (n + 1) / 2;
  while (sum && l < r) {
    if (sum > r - l) {
      sum -= (r - l);
      swap(ar1[l], ar1[r]);
      l++;
      r--;
    } else {
      swap(ar1[r], ar1[r - sum]);
      break;
    }
  }
  sum = 0;
  for (i = 1; i <= n; i++) {
    sum += max(ar[i], ar1[i]);
  }
  cout << sum << '\n';
  for (i = 1; i <= n; i++) {
    cout << ar[i] << ' ';
  }
  cout << '\n';
  for (i = 1; i <= n; i++) {
    cout << ar1[i] << ' ';
  }
}
