#include <bits/stdc++.h>
using namespace std;
const int N = 1000007;
long long n, m, s;
int V[N];
int main() {
  scanf("%lld%lld", &n, &m), s = m;
  if (m < n * (n + 1) >> 1) {
    puts("-1");
    return 0;
  }
  m -= n * (n + 1) >> 1;
  for (int i = 1; i <= n >> 1; ++i) {
    int x = n - i - i + 1;
    if (x <= m)
      m -= x;
    else {
      printf("%lld\n", s);
      for (int j = 1; j <= n; ++j) printf("%d ", j);
      puts("");
      for (int j = 1; j <= i - 1; ++j)
        printf("%lld ", n - j + 1), V[n - j + 1] = 1;
      printf("%lld ", i + m), V[i + m] = 1;
      for (int j = 1; j <= n; ++j)
        if (!V[j]) printf("%d ", j);
      return 0;
    }
  }
  printf("%lld\n", s - m);
  for (int i = 1; i <= n; ++i) printf("%d ", i);
  puts("");
  for (int i = n; i >= 1; --i) printf("%d ", i);
  puts("");
  return 0;
}
