#include <bits/stdc++.h>
using namespace std;
const int NN = (int)1e6 + 6;
int runner[NN];
int n;
long long k;
int main() {
  scanf("%d%lld", &n, &k);
  long long lower_bnd = (1LL * n * (n + 1)) >> 1;
  if (lower_bnd > k)
    printf("-1\n");
  else {
    long long best = lower_bnd;
    memset(runner, -1, sizeof(runner));
    int i = n;
    for (int j = 1; i > j;) {
      if (i - j + best > k) {
        while (i - j + best > k) j++;
        runner[j] = i--;
        break;
      } else {
        best += i - j;
        runner[j++] = i--;
      }
    }
    for (int j = n; j >= 1; j--) {
      if (runner[j] != -1) continue;
      runner[j] = i--;
    }
    best = 0;
    for (int i = 1; i <= n; i++) best += max(i, runner[i]);
    printf("%lld\n", best);
    for (int i = 1; i <= n; i++) {
      if (i > 1) printf(" ");
      printf("%d", i);
    }
    printf("\n");
    for (int i = 1; i <= n; i++) {
      if (i > 1) printf(" ");
      printf("%d", runner[i]);
    }
    printf("\n");
  }
  return 0;
}
