#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vint = vector<int>;
using v2int = vector<vint>;
using vll = vector<ll>;
using ld = long double;
using pld = pair<ld, ld>;
void fail() {
  cout << -1 << endl;
  exit(0);
}
ll getMax(int n) {
  if (n % 2 == 0) {
    return 1ll * (n / 2 + 1 + n) * (n / 2);
  } else {
    return 1ll * (n / 2 + 2 + n) * (n / 2) + (n + 1) / 2;
  }
}
void solve() {
  int n;
  ll k;
  cin >> n >> k;
  for (int i = 1; i < n + 1; ++i) {
    k -= i;
  }
  if (k < 0) {
    fail();
  }
  vector<int> a(n + 1), b(n + 1);
  for (int i = 1; i < n + 1; ++i) {
    a[i] = i;
  }
  vector<bool> fixed(n + 1);
  int pos = 1;
  int mx = n;
  for (int i = 1; i < n + 1; ++i) {
    if (mx - a[i] <= k) {
      b[i] = mx;
      fixed[b[i]] = true;
      k -= mx - a[i];
      mx--;
      pos++;
    } else {
      b[i] = a[i] + k;
      fixed[b[i]] = true;
      k = 0;
      pos++;
      break;
    }
  }
  int num = 1;
  for (; pos <= n; ++pos) {
    while (fixed[num]) num++;
    b[pos] = num++;
  }
  ll ans = 0;
  for (int i = 1; i < n + 1; ++i) {
    ans += max(a[i], b[i]);
  }
  cout << ans << '\n';
  for (int i = 1; i < n + 1; ++i) {
    cout << a[i] << ' ';
  }
  cout << '\n';
  for (int i = 1; i < n + 1; ++i) {
    cout << b[i] << ' ';
  }
  cout << '\n';
}
int main() {
  cin.tie(nullptr);
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  solve();
  return 0;
}
