#include <bits/stdc++.h>
using namespace std;
template <class T>
void printQueue(T& q) {
  while (!q.empty()) {
    cout << q.top() << endl;
    q.pop();
  }
}
long long power(long long a, long long b) {
  long long r = 1;
  while (b != 0) {
    if (b % 2 != 0) {
      r = r * a;
      r %= 100000007;
    }
    a = a * a;
    a = a % 100000007;
    b = b / 2;
  }
  return r;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    long long n, k, z;
    cin >> n >> k;
    long long minm = ((n) * (n + 1)) / 2;
    long long maxm = 0;
    long long a1[n + 1], a2[n + 1];
    for (long long i = 1; i <= n; i++) {
      maxm += max(i, n - i + 1);
      a1[i] = i;
      a2[i] = i;
    }
    if (k < minm) {
      cout << -1 << endl;
      continue;
    }
    if (k > maxm) {
      k = maxm;
    }
    z = k;
    int i = 1;
    k = k - minm;
    while (k != 0) {
      if (k >= (n + 1 - i - i)) {
        a2[i] = a1[n + 1 - i];
        a2[n + 1 - i] = a1[i];
        k = k - (n + 1 - i - i);
        i += 1;
      } else {
        a2[i] = a1[i + k];
        a2[i + k] = a1[i];
        k = 0;
      }
    }
    cout << z << endl;
    long long ut = 0;
    for (int i = 1; i <= n; i++) {
      cout << a1[i] << " ";
    }
    cout << endl;
    for (int i = 1; i <= n; i++) {
      cout << a2[i] << " ";
    }
    cout << endl;
  }
}
