#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using namespace atcoder; typedef long long ll; typedef long double ld; typedef std::pair pii; typedef std::pair pll; typedef std::pair pid; typedef std::pair pls; typedef std::vector vb; typedef std::vector vvb; typedef std::vector vi; typedef std::vector vvi; typedef std::vector vvvi; typedef std::vector vvvvi; typedef std::vector vl; typedef std::vector vvl; typedef std::vector vvvl; typedef std::vector vvvvl; typedef std::vector vd; typedef std::vector vvd; typedef std::vector vs; #define rep(i,n) for(auto i=0; i=0; --i) #define repdm(i,e,n) for(auto i=n-1; i>=e; --i) #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() template inline bool chmax(T& a, T b, int eq = 0) { if (a < b || (a == b && eq)) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b, int eq = 0) { if (a > b || (a == b && eq)) { a = b; return 1; } return 0; } template * = nullptr> constexpr istream& operator>>(istream& is, mint& x) noexcept {long long v = 0; std::cin >> v; x = v; return is;} template * = nullptr> constexpr ostream& operator<<(ostream& os, const mint& x) noexcept {os << x.val(); return os;} inline void _n() { std::cout << std::endl; } template inline void _(const T a) { std::cout << a; } template inline void _l(const T a) { _(a); _n(); } template inline void _s(const T a) { _(a); _(' '); } template inline void _v(const std::vector v) { for(auto a : v) _(a); } template inline void _vl(const std::vector v) { for(auto a : v) _l(a); } template inline void _vs(const std::vector v) { for(auto a : v) _s(a); _n(); } template inline void _vvl(const std::vector> v) { for(auto a : v) { _v(a); _n(); } } template inline void _vvs(const std::vector> v) { for(auto a : v) { _vs(a); } } inline void ynl(const bool b) {_l(b ? "yes" : "no");} inline void yns(const bool b) {_l(b ? "Yes" : "No");} inline void ynu(const bool b) {_l(b ? "YES" : "NO");} constexpr int INF = numeric_limits::max() >> 1; constexpr long long INF_LL = numeric_limits::max() >> 1LL; const long long MOD1 = 1000000007; const long long MOD9 = 998244353; using mint1 = atcoder::modint1000000007; using mint9 = atcoder::modint998244353; //* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *// void input() { } void solve() { int N, M; cin >> N >> M; int pct_all = 0; vvi pct_mat(N, vi(N)); rep(i, N) rep(j, N) { int tmp = (i+1) * (j+1); int pct = (int)bitset<8>(tmp).count(); pct_mat[i][j] = 1 - (pct % 2); pct_all += pct_mat[i][j]; } // _vvs(pct_mat); // _l(pct_all); vi cnt(N); rep(i, N) rep(j, N) { cnt[i] += 2 * pct_mat[i][j]; } // _vs(cnt); int fy = pct_all - M; // _l(fy); vvi dp(N+1, vi(N*N+1)); vvi prev(N+1, vi(N*N+1)); dp[0][0] = 1; rep(i, N) { rep(j, N*N+1) { dp[i+1][j] |= dp[i][j]; prev[i+1][j] = prev[i][j]; if(j >= cnt[i]) { int flg = dp[i+1][j] == 0; dp[i+1][j] |= dp[i][j - cnt[i]]; if(flg && dp[i+1][j]) { prev[i+1][j] = i+1; } } } } // _l(prev[N][fy]); // rep(i, N*N+1) _s(i%10); // _n(); // _vvs(dp); // _n(); // _vvs(prev); if(dp[N][fy]) { int tmp_c = N; int tmp_s = fy; vi ans_x; while(tmp_s > 0) { ans_x.push_back(prev[tmp_c][tmp_s]); tmp_c = prev[tmp_c][tmp_s]; tmp_s -= cnt[tmp_c-1]; } sort(all(ans_x)); //_vs(ans_y); vi ans_y; rep(i, N) { if(find(all(ans_x), i+1) == ans_x.end()) { ans_y.push_back(i+1); } } _s(ans_x.size()); _l(ans_y.size()); _vs(ans_x); _vs(ans_y); } else { _l(-1); } } //* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *// int main() { std::ifstream in("input.txt"); std::cin.rdbuf(in.rdbuf()); std::cin.tie(0); std::ios::sync_with_stdio(false); input(); solve(); return 0; }