#include <bits/stdc++.h>
using namespace std;
int a[1000006], b[1000006];
int main() {
  ios_base::sync_with_stdio(false);
  long long n, k, c, t;
  cin >> n >> k;
  c = k;
  vector<long long> b(n + 1);
  if (k < n * (n + 1) / 2) return puts("-1"), 0;
  k -= (n * (n + 1) / 2);
  int x = 1, y = n;
  while (x < y && k >= y - x) {
    b[y] = x;
    b[x] = y;
    k -= (y - x);
    x++;
    y--;
  }
  if (k && x < y) b[x] = x + k, b[x + k] = x, k = 0;
  cout << c - k << endl;
  for (int i = 1; i <= n; i++) cout << i << " ";
  cout << endl;
  for (int i = 1; i <= n; i++) cout << (b[i] ? b[i] : i) << " ";
  return 0;
}
