#include using namespace std; const int INF = 100000000; int main(){ random_device rnd; mt19937 mt(rnd()); int N, M; cin >> N >> M; vector> p(N, vector(N)); for (int i = 0; i < N; i++){ for (int j = 0; j < N; j++){ p[i][j] = 1 - __builtin_parity((i + 1) * (j + 1)); } } vector X(N, true); int D = 0; for (int i = 0; i < N; i++){ for (int j = 0; j < N; j++){ D += p[i][j]; } } bool ok = false; for (int i = 0; i < 100000; i++){ int x = mt() % N; int diff = 0; for (int j = 0; j < N; j++){ diff += p[x][j] * 2; } if (X[x]){ diff *= -1; } if (D + diff == M){ X[x] = !X[x]; vector ansx, ansy; for (int j = 0; j < N; j++){ if (X[j]){ ansx.push_back(j); } else { ansy.push_back(j); } } int P = ansx.size(); int Q = ansy.size(); cout << P << ' ' << Q << endl; for (int j = 0; j < P; j++){ cout << ansx[j] + 1; if (j < P - 1){ cout << ' '; } } cout << endl; for (int j = 0; j < Q; j++){ cout << ansy[j] + 1; if (j < Q - 1){ cout << ' '; } } cout << endl; ok = true; break; } int D2 = D + diff; int d = abs(D2 - M) - abs(D - M); double t = (double) i / 100000; double temp = 3.5 - 3.4 * t; double p = exp(-d / temp); if (!isinf(p)){ if (mt() % INF < p * INF){ X[x] = !X[x]; D = D2; } } } if (!ok){ cout << -1 << endl; } }