#include <bits/stdc++.h>
using namespace std;
void setIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const long long N = 1e6 + 5;
const long long inf = 9e17;
const long long mod = 1e9 + 7;
long long xyz = 1;
long long n, k;
long long ans[N];
long long get(long long l, long long r) { return (r - l + 1) * (l + r) / 2; }
long long fnd(long long l, long long r) {
  long long n = r - l + 1;
  long long mid = (r + l + 1) / 2;
  long long res = get(mid, r) * 2 - (n & 1 ? mid : 0);
  return res;
}
void run() {
  cin >> n >> k;
  long long add = k - get(1, n);
  if (add < 0) {
    cout << "-1\n";
    return;
  }
  iota(ans, ans + n, 1);
  if (fnd(1, n) < k) {
    cout << fnd(1, n) << "\n";
  } else
    cout << k << endl;
  for (long long i = 0; i < n; i++) cout << ans[i] << " ";
  cout << "\n";
  for (long long i = 0; i < n / 2; i++) {
    long long big = n - i * 2 - 1;
    if (big <= add) {
      add -= big, swap(ans[i], ans[n - i - 1]);
    } else {
      for (long long j = i; j < n; j++)
        if (ans[n - i - 1] - ans[j] == add) {
          add = 0, swap(ans[n - i - 1], ans[j]);
          break;
        }
    }
    if (!add) break;
  }
  for (long long i = 0; i < n; i++) cout << ans[i] << " ";
  cout << "\n";
}
signed main() {
  setIO();
  while (xyz--) run();
  return 0;
}
