#include <bits/stdc++.h>
using namespace std;
int n;
long long k;
int p[1000010];
int q[1000010];
int main() {
  scanf("%d %I64d", &n, &k);
  k -= (long long)n * (n + 1) / 2;
  if (k < 0) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i <= n; i++) p[i] = i;
  for (int i = 1; k > 0 && n - i + 1 > i; i++) {
    if (k > n - 2 * i + 1) {
      k -= n - 2 * i + 1;
      q[i] = n - i + 1;
    } else {
      q[n - i + 1 - k] = n - i + 1;
      k = 0;
    }
  }
  int s = 0;
  for (int i = 1; i <= n; i++)
    if (!q[i]) q[i] = ++s;
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans += max(p[i], q[i]);
  printf("%I64d\n", ans);
  for (int i = 1; i <= n; i++) printf("%d%c", p[i], i == n ? '\n' : ' ');
  for (int i = 1; i <= n; i++) printf("%d%c", q[i], i == n ? '\n' : ' ');
  return 0;
}
