#include <bits/stdc++.h>
using namespace std;
int arr[10000005];
int ans[2][10000005];
int main() {
  long long n, K;
  cin >> n >> K;
  K -= n * (n + 1) / 2;
  if (K < 0) {
    cout << -1;
    return 0;
  }
  for (int x = n - 1; x >= 1; x -= 2) {
    if (K == 0) break;
    if (x < K) {
      arr[x]++;
      K -= x;
    } else {
      arr[K]++;
      K -= K;
    }
  }
  for (int i = n; i >= 1; i--) arr[i] += arr[i + 1];
  for (int i = 1; i <= n; i++) arr[i] += i;
  for (int i = 1; i <= n; i++) ans[0][i] = ans[1][i] = i;
  for (int i = 1; i <= n; i++) {
    if (arr[i] == arr[i - 1])
      ans[0][arr[i]] = 0;
    else
      ans[1][arr[i]] = 0;
  }
  queue<int> top, bottom;
  for (int i = 1; i <= n; i++) {
    if (ans[0][i] != 0) top.push(i);
    if (ans[1][i] != 0) bottom.push(i);
  }
  for (int i = 1; i <= n; i++) {
    ans[0][i] = ans[1][i] = 0;
    if (arr[i] == arr[i - 1])
      ans[0][i] = arr[i];
    else
      ans[1][i] = arr[i];
  }
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    if (ans[0][i] == 0) ans[0][i] = top.front(), top.pop();
    if (ans[1][i] == 0) ans[1][i] = bottom.front(), bottom.pop();
    res += max(ans[0][i], ans[1][i]);
  }
  cout << res << "\n";
  for (int i = 1; i <= n; i++) cout << ans[0][i] << " ";
  cout << "\n";
  for (int i = 1; i <= n; i++) cout << ans[1][i] << " ";
  cout << "\n";
}
