#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6 + 10;
int a[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n, k;
  cin >> n >> k;
  ll mn = (n + 1) * n / 2;
  if (k < mn) {
    puts("-1");
    return 0;
  }
  for (int i = 1; i <= n; ++i) a[i] = i;
  k -= mn;
  for (int i = 1; i <= n / 2; ++i) {
    int x = n - i + 1;
    if (x - i < k) {
      k -= x - i;
      swap(a[i], a[x]);
    } else {
      swap(a[x - k], a[x]);
      break;
    }
  }
  ll ans = 0;
  for (int i = 1; i <= n; ++i) ans += max(a[i], i);
  printf("%lld\n", ans);
  for (int i = 1; i <= n; ++i) printf("%d ", i);
  printf("\n");
  for (int i = 1; i <= n; ++i) printf("%d ", a[i]);
  printf("\n");
  return 0;
}
