#include <bits/stdc++.h>
using namespace std;
long long mx[1000001];
int P[1000001];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(30);
  cout << fixed;
  int n;
  long long k;
  cin >> n >> k;
  long long base = n * (n + 1ll) / 2;
  k -= base;
  if (k < 0) {
    printf("-1\n");
    return 0;
  }
  mx[1] = 0;
  for (int i = 2; i <= n; ++i) {
    mx[i] = mx[i - 1] + i / 2;
    if (i <= 10)
      ;
  }
  if (k == 0) {
    printf("%lld\n", base);
    for (int i = 1; i <= n; ++i) printf("%d ", i);
    printf("\n");
    for (int i = 1; i <= n; ++i) printf("%d ", i);
    printf("\n");
    return 0;
  }
  if (mx[n] <= k) {
    printf("%lld\n", base + mx[n]);
    for (int i = 1; i <= n; ++i) printf("%d ", i);
    printf("\n");
    for (int i = 1; i <= n; ++i) printf("%d ", n + 1 - i);
    printf("\n");
    return 0;
  }
  printf("%lld\n", base + k);
  for (int i = 1; i <= n; ++i) printf("%d ", i);
  printf("\n");
  int l;
  for (l = n - 1; l > 0; --l) {
    if (mx[l] <= k) break;
  }
  for (int i = 1; i <= l; ++i) P[i] = l + 1 - i;
  for (int i = l + 1; i <= n; ++i) P[i] = i;
  for (int i = 1; i <= l; ++i) {
    if (mx[l] - max(P[i], i) + l + 1 == k) {
      swap(P[i], P[l + 1]);
      break;
    }
  }
  for (int i = 1; i <= n; ++i) printf("%d ", P[i]);
  printf("\n");
  return 0;
}
