#include using namespace std; typedef long long ll; typedef pair P; #define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0) #define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0) templateostream& operator<<(ostream& os,const pair& a) {os << "(" << a.first << ", " << a.second << ")";return os;} const char newl = '\n'; int main() { int n; cin >> n; vector g(n+1); g[0] = 0; for (int i = 1;i < n+1;++i) { vector f(n+1,false); for (int j = 0;j < i;++j) f[g[j]^g[i-j-1]] = true; for (int j = 0;j < i-1;++j) f[g[j]^g[i-j-2]] = true; for (int j = 0;j < n+1;++j) if (f[j] == false) { g[i] = j; break; } } vector a(n+1,false); a[n] = true; while (1) { bool f = false; for (int i = 0;i < n;++i) if (!a[i]) { int grundy = 0,cnt = 0; a[i] = true; for (int j = 0;j < n+1;++j) { if (a[j]) { grundy ^= cnt; cnt = -1; } cnt++; } if (grundy == 0) { cout << "1 " << i+1 << endl; f = true; break; } a[i] = false; } if (!f) for (int i = 0;i < n-1;++i) if ((!a[i]) && (!a[i+1])) { int grundy = 0,cnt = 0; a[i] = a[i+1] = true; for (int j = 0;j < n+1;++j) { if (a[j]) { grundy ^= cnt; cnt = -1; } cnt++; } if (grundy == 0) { cout << "2 " << i+1 << endl; break; } a[i] = a[i+1] = false; } int t,k,x; cin >> t; if (t < 3) return 0; cin >> k >> x; a[x-1] = true; if (k-1) a[x] = true; } }