#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 100;
int a[maxn], b[maxn];
int main() {
  long long n, k;
  cin >> n >> k;
  if ((n * (n + 1) / 2) > k) {
    cout << "-1" << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) a[i] = i + 1;
  long long tmp = n * (n + 1) / 2;
  long long end = n - 1;
  for (long long s = 0; s < end && tmp < k; s++) {
    while (s < end && tmp + end - s > k) end--;
    tmp += end - s;
    swap(a[s], a[end]);
    end--;
  }
  cout << tmp << endl;
  for (int i = 0; i < n; i++) cout << i + 1 << " ";
  cout << endl;
  for (int i = 0; i < n; i++) cout << a[i] << " ";
  cout << endl;
}
