#include <bits/stdc++.h>
using namespace std;
template <class t>
inline t read(t &x) {
  char c = getchar();
  bool f = 0;
  x = 0;
  while (!isdigit(c)) f |= c == '-', c = getchar();
  while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  if (f) x = -x;
  return x;
}
template <class t>
inline void write(t x) {
  if (x < 0)
    putchar('-'), write(-x);
  else {
    if (x > 9) write(x / 10);
    putchar('0' + x % 10);
  }
}
const long long N = 1e6 + 5;
long long n, k, a[N];
bool v[N];
signed main() {
  read(n);
  read(k);
  if (k < (n + 1) * n / 2) {
    write(-1);
    return 0;
  }
  k -= (n + 1) * n / 2;
  for (long long i = 1; i <= n; i++) {
    if (k >= n - i + 1 - i) {
      k -= n - i + 1 - i;
      a[i] = n - i + 1;
      v[n - i + 1] = 1;
    } else {
      a[i] = i + k;
      v[i + k] = 1;
      for (long long j = i + 1, pt = 1; j <= n; j++) {
        while (v[pt]) pt++;
        a[j] = pt;
        v[pt] = 1;
      }
      break;
    }
  }
  k = 0;
  for (long long i = 1; i <= n; i++) k += max(i, a[i]);
  write(k);
  puts("");
  for (long long i = 1; i <= n; i++) write(i), putchar(' ');
  puts("");
  for (long long i = 1; i <= n; i++) write(a[i]), putchar(' ');
}
