http://codeforces.com/contest/1244/problem/G
#include <bits/stdc++.h>
//#include <queue>
//#include <cmath>
//#include <iostream>
//#include <unordered_map>
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(x) ((x)&(-x))
#define mem(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define INF 0x3f3f3f3f
#define ll long long
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int mod=1e9+7;
const int N=1e6+9;
int ans[N];
int main()
{
FAST_IO;
int n;
ll k;
while(cin>>n>>k)
{
ll sum=k;
for(int i=1;i<=n;i++)
{
ans[i]=i;
sum-=i;
}
if(sum<0)
{
cout<<-1<<endl;
continue;
}
for(int i=1;i<=n/2;i++)
{
int d=(n-i+1)-i;
if(sum<=d)
{
swap(ans[i],ans[n-i+1-(d-sum)]);
sum=0;
break;
}
swap(ans[i],ans[n-i+1]);
sum-=d;
}
cout<<k-sum<<endl;
for(int i=1;i<=n;i++) cout<<i<<" ";
cout<<endl;
for(int i=1;i<=n;i++) cout<<ans[i]<<" ";
cout<<endl;
}
return 0;
}