#include #include "testlib.h" //using namespace std; #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define rep(i, j, n) for(ll i = ll(j); i < ll(n); i++) #define REP(i, j, n) for(ll i = ll(j); i <= ll(n); i++) #define per(i, j, n) for(ll i = ll(j); ll(n) <= i; i--) #define ALL(a) (a).begin(),(a).end() #define revALL(a) (a).rbegin(),(a).rend() #define pb emplace_back #define mp std::make_pair #define mtp std::make_tuple #define ln "\n" using std::endl; using std::cin; using std::cout; using ll = long long; using lint = __int128; using std::vector; using std::string; using std::upper_bound; using std::lower_bound; using vi = vector; using vii = vector; using pii = std::pair; using vs = vector; using vss = vector; using pss = std::pair; using vl = vector; using vll = vector; using pll = std::pair; //main int main(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); std::random_device rnd; std::mt19937 mt(rnd()); registerValidation(); ll N,M; N = inf.readInt(1,300,"N"); inf.readSpace(); M = inf.readInt(0,N*N,"M"); inf.readEoln(); vi cnt(N+1); REP(i,1,N){ REP(j,1,N){ if(__builtin_popcount(i*j)%2 == 0) cnt[i]++; } } vector> dp(N+1,vector(2*N*N+1)); dp[0][N*N] = true; REP(i,1,N){ REP(j,0,2*N*N){ if(!dp[i-1][j]) continue; if(cnt[i] <= j) dp[i][j-cnt[i]] = true; if(j+cnt[i] <= 2*N*N) dp[i][j+cnt[i]] = true; } } M += N*N; if(dp[N][M]){ vi P,Q; per(i,N,1){ if(M+cnt[i]<=2*N*N && dp[i-1][M+cnt[i]]){ Q.pb(i); M += cnt[i]; } else{ P.pb(i); M -= cnt[i]; } } cout << P.size() << " " << Q.size() << ln; for(auto p:P) cout << p << ln; for(auto q:Q) cout << q << ln; } else{ cout << -1 << ln; } inf.readEof(); }