#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using ll = long long;
using vll = vector<ll>;
int n;
ll k;
int a[1000006];
int main() {
  scanf("%d %lld", &n, &k);
  ll mn = 1LL * n * (n + 1) / 2;
  if (k < mn) {
    printf("-1\n");
    return 0;
  }
  ll mx = 1LL * n * (n + 1) - 1LL * (n / 2) * (n / 2 + 1);
  if (n & 1) mx -= (n + 1) / 2;
  if (k > mx) {
    k = mx;
  }
  ll ans = k;
  for (int i = 1; i <= n; ++i) a[i] = i;
  mx = mx - mn;
  k -= mn;
  int l = 1, r = n;
  while (k > 0) {
    r = min(1LL * r, l + k);
    swap(a[l], a[r]);
    k -= r - l;
    ++l;
    --r;
  }
  printf("%lld\n", ans);
  for (int i = 1; i <= n; ++i) printf("%d ", i);
  printf("\n");
  for (int i = 1; i <= n; ++i) printf("%d ", a[i]);
  printf("\n");
}
