#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 6;
int ans[N];
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  long long n, k;
  cin >> n >> k;
  for (int i = 1; i < n + 1; ++i) ans[i] = i;
  if (k < n * (n + 1) / 2) {
    cout << -1 << '\n';
    return 0;
  }
  long long res = 0;
  k = min(k, n * (n + 1) / 2 + (n + 1) / 2 * (n / 2));
  res = k;
  k -= n * (n + 1) / 2;
  for (int i = 1; i < n + 1; ++i) {
    if (k == 0) break;
    int pos = n - i + 1 - i;
    if (pos <= k) {
      k -= pos;
      swap(ans[i], ans[n - i + 1]);
    } else {
      swap(ans[i], ans[i + k]);
      k = 0;
    }
  }
  cout << res << '\n';
  for (int i = 1; i < n + 1; ++i) cout << i << ' ';
  cout << '\n';
  for (int i = 1; i < n + 1; ++i) cout << ans[i] << ' ';
  cout << '\n';
}
