#include <bits/stdc++.h>
using namespace std;
long long a, n, k, i, j, p[1050001], q[1050001];
int main() {
  cin >> n >> k;
  if (k < n * (n + 1) >> 1) return puts("-1");
  a = n * (n + 1) >> 1;
  for (i = 1; i <= n; i++) p[i] = q[i] = i;
  for (i = 1, j = n; i < j; i++)
    if (a + j - i <= k) a += j - i, swap(p[i], p[j--]);
  cout << a << endl;
  for (i = 0; i < n;) cout << p[++i] << ' ';
  puts("");
  for (i = 0; i < n;) cout << q[++i] << ' ';
}
