#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
long long ans[maxn];
long long n, k;
int main() {
  scanf("%lld%lld", &n, &k);
  for (int i = 1; i <= n; ++i) {
    ans[i] = i;
    k -= i;
  }
  if (k < 0) return 0 * puts("-1");
  int pn = n;
  for (int i = 1; i <= pn; ++i) {
    if (k >= ans[pn] - ans[i]) {
      k -= ans[pn] - ans[i];
      swap(ans[pn], ans[i]);
      --pn;
    }
  }
  long long sum = 0;
  for (int i = 1; i <= n; ++i) sum += max(1ll * i, ans[i]);
  printf("%lld\n", sum);
  for (int i = 1; i <= n; ++i) printf("%d ", i);
  puts("");
  for (int i = 1; i <= n; ++i) printf("%lld ", ans[i]);
  puts("");
  return 0;
}
