#include <bits/stdc++.h>
using namespace std;
long long n, k, ar[1000005], br[1000005];
int main() {
  scanf("%lld %lld", &n, &k);
  long long min_ = 0, max_ = 0;
  for (int i = 1; i < n + 1; i++) {
    ar[i] = br[i] = i;
    min_ += i;
    max_ += max((long long)i, n - i + 1);
  }
  if (k < min_) {
    cout << "-1";
    return 0;
  } else {
    long long tot = min_;
    long long t = n - 1;
    k -= min_;
    for (int i = 1; i < n + 1; i++) {
      if (i >= n + 1 - i) break;
      if (k > t) {
        tot += t;
        min_ += t;
        swap(br[i], br[n + 1 - i]);
      } else {
        tot += k;
        min_ += k;
        swap(br[i], br[i + k]);
        break;
      }
      k -= t;
      t -= 2;
    }
    cout << tot << "\n";
  }
  for (int i = 1; i < n + 1; i++) cout << ar[i] << " ";
  cout << "\n";
  for (int i = 1; i < n + 1; i++) cout << br[i] << " ";
  cout << "\n";
}
