#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long n, k;
int a[1000010], b[1000010];
int main() {
  scanf("%lld%lld", &n, &k);
  long long ad =
      (n % 2) ? (2 + (n - 1)) * (n / 2) / 2 : (n - 1 + 1) * (n / 2) / 2;
  if (k < (1 + n) * n / 2) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i <= n; ++i) {
    a[i] = b[i] = i;
  }
  if (k >= (1 + n) * n / 2 + ad) {
    for (int i = 1; i <= n / 2; ++i) {
      swap(b[i], b[n - i + 1]);
    }
    printf("%lld\n", (1 + n) * n / 2 + ad);
    for (int i = 1; i <= n; ++i) {
      printf("%d ", a[i]);
    }
    printf("\n");
    for (int i = 1; i <= n; ++i) {
      printf("%d ", b[i]);
    }
    return 0;
  }
  int l = 1, r = n;
  long long dd = k - (1 + n) * n / 2, now = n - 1;
  while (dd > now) {
    dd -= now;
    swap(b[l], b[r]);
    now -= 2;
    l++, r--;
  }
  if (dd != 0) {
    swap(b[l], b[l + dd]);
  }
  printf("%lld\n", k);
  for (int i = 1; i <= n; ++i) {
    printf("%d ", a[i]);
  }
  printf("\n");
  for (int i = 1; i <= n; ++i) {
    printf("%d ", b[i]);
  }
  return 0;
}
