#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, M = 1 << 20 | 10;
const int mod = 1e9 + 7;
long long n, m, sum;
int a[M];
int main() {
  scanf("%lld%lld", &n, &m);
  for (int i = 1; i <= n; i++) a[i] = i, sum += i;
  if (sum > m) return puts("-1"), 0;
  for (int i = 1, j = n; i <= j;) {
    if (sum + j - i <= m)
      swap(a[i], a[j]), sum += j - i, i++, j--;
    else
      j--;
  }
  printf("%lld\n", sum);
  for (int i = 1; i <= n; i++) printf("%d ", i);
  puts("");
  for (int i = 1; i <= n; i++) printf("%d ", a[i]);
  puts("");
}
