#include <bits/stdc++.h>
using namespace std;
const int maxsize = 1000005;
const int inf = 1061109567;
long long int x, y;
int a[maxsize], b[maxsize];
int main() {
  cin >> x >> y;
  for (int i = 1; i <= x; i++) a[i] = i, b[i] = i;
  long long int ans;
  ans = y - x * (x + 1) / 2;
  if (ans < 0) {
    puts("-1");
    return 0;
  }
  int li = 1, ri = x;
  while (ans && li < ri) {
    if (ans >= ri - li) {
      ans -= ri - li;
      swap(b[ri], b[li]);
      ri--;
      li++;
    } else
      li++;
  }
  cout << y - ans << endl;
  for (int i = 1; i <= x; i++) printf("%d ", a[i]);
  printf("\n");
  for (int i = 1; i <= x; i++) printf("%d ", b[i]);
  printf("\n");
  return 0;
}
