#include <bits/stdc++.h>
using namespace std;
template <class T>
using minheap = priority_queue<T, vector<T>, greater<T>>;
long long n, k;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  long long mn = n * (n + 1) / 2;
  if (k < mn) {
    cout << -1 << '\n';
    return 0;
  }
  k -= mn;
  vector<int> p(n);
  iota(p.begin(), p.end(), 1);
  vector<int> q = p;
  int L = 0, R = n - 1;
  while (L <= R) {
    if (k >= R - L) {
      k -= R - L;
      swap(q[L], q[R]);
      L++;
      R--;
    } else {
      swap(q[R - k], q[R]);
      break;
    }
  }
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += max(p[i], q[i]);
  }
  cout << sum << '\n';
  for (int i : p) cout << i << " ";
  cout << '\n';
  for (int i : q) cout << i << " ";
  cout << '\n';
  return 0;
}
