#include <bits/stdc++.h>
using namespace std;
const long long N = 1000010;
long long b[N];
long long a[N];
bool st[N];
signed main() {
  ios::sync_with_stdio(0);
  long long n, k;
  cin >> n >> k;
  long long tot = 0;
  for (long long i = 1; i <= n; i++) {
    tot += i;
    a[i] = i;
    b[i] = i;
  }
  if (k < tot) {
    cout << -1 << endl;
    return 0;
  }
  tot = k - tot;
  long long maxv = n;
  for (long long i = 1; i <= n; i++) {
    if (tot) {
      if (tot - (maxv - i) < 0) {
        long long tt = tot;
        long long j = i + tot;
        while (st[j]) j--;
        if (i < j) swap(b[i], b[j]);
        break;
      } else {
        if (i < maxv) tot -= maxv - i, swap(b[i], b[maxv--]);
      }
    }
  }
  long long res = 0;
  for (long long i = 1; i <= n; i++) res += max(a[i], b[i]);
  cout << res << endl;
  for (long long i = 1; i <= n; i++) cout << a[i] << " ";
  cout << endl;
  for (long long i = 1; i <= n; i++) cout << b[i] << " ";
  cout << endl;
  return 0;
}
