#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000005;
int n, b[maxn];
long long k;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  if (k < 1LL * n * (n + 1) / 2) {
    cout << -1 << '\n';
    return 0;
  }
  long long rem = k - 1LL * n * (n + 1) / 2;
  set<int> fuck;
  for (int i = 1; i <= n; i++) fuck.insert(i);
  int idx = n + 1;
  for (int i = 1; i <= n; i++) {
    int mx = max(0, n - i - i + 1);
    int tk = (int)min(rem, (long long)mx);
    if (tk == 0) {
      idx = i;
      break;
    }
    b[i] = i + tk;
    fuck.erase(b[i]);
    rem -= tk;
  }
  cout << k - rem << '\n';
  int cnt = 0;
  for (int i = idx; i <= n; i++) {
    b[i] = *fuck.begin();
    fuck.erase(fuck.begin());
  }
  for (int i = 1; i <= n; i++) cout << i << " ";
  cout << '\n';
  for (int i = 1; i <= n; i++) cout << b[i] << " ";
}
