#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k;
  cin >> n >> k;
  if (k < n * (n + 1) / 2) {
    cout << -1;
    return 0;
  }
  vector<long long> v1, v2;
  v1.push_back(0);
  v2.push_back(0);
  for (long long i = 1; i < n + 1; i++) v1.push_back(i), v2.push_back(i);
  k -= n * (n + 1) / 2;
  long long lp = 1, rp = n;
  while (lp <= rp && k > 0) {
    long long diff = v2[rp] - v2[lp];
    if (diff <= k) {
      k -= diff;
      swap(v2[lp], v2[rp]);
      lp++;
      rp--;
    } else {
      while (lp <= rp) {
        if (v2[rp] - v2[lp] <= k) break;
        rp--;
      }
      if (rp >= lp) {
        swap(v2[lp], v2[rp]);
        break;
      }
    }
  }
  long long ans = 0;
  for (long long i = 1; i < n + 1; i++) ans += max(v1[i], v2[i]);
  cout << ans << "\n";
  for (long long i = 1; i < n + 1; i++) cout << v1[i] << " ";
  cout << "\n";
  for (long long i = 1; i < n + 1; i++) cout << v2[i] << " ";
  return 0;
}
