#include <bits/stdc++.h>
using namespace std;
int a[1000005];
int main() {
  long long int n, k;
  cin >> n >> k;
  long long int k_ = k;
  k -= n * (n + 1) / 2;
  if (k < 0) {
    cout << "-1" << endl;
    return 0;
  }
  for (int i = 0; i < (n - 1); ++i) {
    long long int plus = n - 1 - i;
    long long int minus = min(plus, (long long int)i);
    if (plus - minus <= k) {
      k -= plus - minus;
    } else {
      for (int j = 0; j < (n); ++j) {
        if (i + 1 + j <= n) {
          a[j] = i + 1 + j;
        } else {
          a[j] = n - j;
        }
      }
      if (k == 0) {
        cout << k_ << endl;
        for (int j = 1; j < n + 1; ++j) cout << j << ' ';
        cout << endl;
        for (int j = 0; j < (n); ++j) cout << a[j] << ' ';
        cout << endl;
        return 0;
      }
      for (int j = 0; j < (n - 1); ++j) {
        k += max(j + 1, a[j]) + max(j + 2, a[j + 1]);
        k -= max(j + 1, a[j + 1]) + max(j + 2, a[j]);
        swap(a[j], a[j + 1]);
        if (k == 0) {
          cout << k_ << endl;
          for (int j = 1; j < n + 1; ++j) cout << j << ' ';
          cout << endl;
          for (int j = 0; j < (n); ++j) cout << a[j] << ' ';
          cout << endl;
          return 0;
        }
      }
    }
  }
  cout << k_ - k << endl;
  for (int i = 1; i < n + 1; ++i) cout << i << ' ';
  cout << endl;
  for (int i = 0; i < (n); ++i) cout << n - i << ' ';
  cout << endl;
  return 0;
}
