#include <bits/stdc++.h>
using namespace std;
const long long N = 100005;
char en = '\n';
long long inf = 1e16;
long long mod = 1e9 + 7;
long long power(long long x, long long n, long long mod) {
  long long res = 1;
  x %= mod;
  while (n) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long curr = n * (n + 1) / 2;
  if (curr > k) {
    cout << -1 << en;
    return 0;
  }
  long long arr[n + 5];
  for (long long i = 1; i <= n; i++) arr[i] = i;
  long long rem = k - curr;
  long long start = 1;
  while (rem) {
    long long end1 = n - start + 1;
    long long max1 = end1 - start;
    if (max1 <= 0) break;
    if (rem >= max1) {
      swap(arr[start], arr[end1]);
      rem -= max1;
    } else {
      swap(arr[start], arr[start + rem]);
      break;
    }
    start++;
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    ans += max(i, arr[i]);
  }
  cout << ans << en;
  for (long long i = 1; i <= n; i++) cout << i << " ";
  cout << en;
  for (long long i = 1; i <= n; i++) cout << arr[i] << " ";
  cout << en;
  return 0;
}
