#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long a = 0, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) a = (a << 3) + (a << 1) + ch - '0';
  return a * f;
}
const long long mod = 1e9 + 7;
const long long N = 1e6 + 5;
const long long inf = 0x3f3f3f3f;
const long long INF = 2147483647;
const double PI = acos(-1);
long long n, k, a[N], b[N], g;
signed main() {
  n = read();
  g = k = read();
  if (n * (n + 1) > 2 * k) return puts("-1"), 0;
  for (long long i = 1; i <= n; i++) a[i] = b[i] = i;
  k -= n * (n + 1) / 2;
  for (long long i = 1; i <= n / 2; i++) {
    if ((n - 2 * i + 1) >= k) {
      swap(a[i], a[i + k]);
      printf("%lld\n", g);
      for (long long j = 1; j <= n; j++) printf("%lld ", a[j]);
      puts("");
      for (long long j = 1; j <= n; j++) printf("%lld ", b[j]);
      return 0;
    }
    swap(a[i], a[n - i + 1]);
    k -= (n - 2 * i + 1);
  }
  printf("%lld\n", g - k);
  for (long long i = 1; i <= n; i++) printf("%lld ", a[i]);
  puts("");
  for (long long i = 1; i <= n; i++) printf("%lld ", b[i]);
  return 0;
}
