#include <bits/stdc++.h>
using namespace std;
long long num[1000005];
int ans[1000005][2];
int cont[1000005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, k, sum = 0;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    num[i] = n - i + 1;
    cont[i] = 2;
  }
  sum = (1 + n) * n / 2;
  if (sum > k) {
    cout << -1 << endl;
  } else {
    k -= sum;
    for (int i = 2; i <= n; i++) {
      int top = n - (i - 1) / 2;
      int dis = top - num[i];
      if (dis <= k) {
        num[i] = top;
        k -= dis;
      } else {
        num[i] = num[i] + k;
        break;
      }
    }
    for (int i = 1; i <= n; i++) {
      ans[i][i % 2] = num[i];
      cont[num[i]]--;
    }
    int loc = 1;
    for (int i = n; i >= 1; i--) {
      if (ans[i][i % 2] != 0) {
        ans[i][(i + 1) % 2] = loc;
        cont[loc]--;
        if (cont[loc] == 0) loc++;
      } else {
        ans[i][i % 2] = loc;
        cont[loc]--;
        if (cont[loc] == 0) loc++;
      }
    }
    sum = 0;
    for (int i = 1; i <= n; i++) {
      sum += 1LL * max(ans[i][0], ans[i][1]);
    }
    cout << sum << endl;
    for (int i = 1; i <= n; i++) {
      cout << ans[i][0] << " ";
    }
    cout << endl;
    for (int i = 1; i <= n; i++) {
      cout << ans[i][1] << " ";
    }
    cout << endl;
  }
  return 0;
}
