#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 10;
const long long MAX = 1000;
const long long inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
long long n, m;
long long a[maxn];
long long b[maxn];
signed main() {
  std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  long long minn = (n + 1) * n / 2;
  if (m < minn) {
    puts("-1");
    return 0;
  }
  for (long long i = (1); i <= (n); ++i) a[i] = i;
  for (long long i = (1); i <= (n); ++i) b[i] = i;
  long long sum = minn;
  long long pos = -1;
  for (long long i = (1); i <= ((n) / 2); ++i) {
    long long ii = n - i + 1;
    long long delta = (ii - i);
    if (sum + delta < m) {
      swap(b[i], b[n - i + 1]);
      sum += delta;
    } else {
      pos = i;
      break;
    }
  }
  if (pos != -1) {
    long long j = pos;
    long long del = m - sum;
    long long jj = j + del;
    swap(b[j], b[jj]);
    sum += jj - j;
  }
  printf("%lld\n", sum);
  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]);
  puts("");
  return 0;
}
