boolcheck(int a, int b, int c, int d, STU t){ if ((a == t.q) + (b == t.b) + (c == t.s) + (d == t.g) == t.cnt) returntrue; returnfalse; }
voidsol(){ int n; cin >> n; vector<STU> arr(n); for (int i = 0; i < n; i++){ int x, k; cin >> x >> k; arr[i].q = x / 1000; arr[i].b = x % 1000 / 100; arr[i].s = x / 10 % 10; arr[i].g = x % 10; arr[i].cnt = k; } for (int a = 0; a <= 9; a++) for (int b = 0; b <= 9; b++) for (int c = 0; c <= 9; c++) for (int d = 0; d <= 9; d++){ bool f = true; for (int i = 0; i < n; i++) if (!check(a, b, c, d, arr[i])){ f = false; break; } if (f){ cout << a << b << c << d << endl; return; } } }
intmain(){ IO int t; cin >> t; while (t--) sol(); return0; }
voidsol(){ int n, m; cin >> n >> m; int lst = -1; bool ans = true; for (int i = 0; i < n; i ++){ bool f = true; int minn = 1000; for (int j = 0; j < m; j ++){ int x; cin >> x; if (x > lst){ minn = min(minn, x); f = false; } } if (!f){ lst = minn; } else{ ans = false; } } if (ans) cout << "YES" << endl; else cout << "NO" << endl; }
intmain(){ ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) sol(); return0; }
intsg(int x){ if (f[x] != -1) return f[x]; unordered_set<int> se; for (int i = 0; i < n; i++) if ((x >> i) & 1){ int nxt = x ^ (1 << i); if (xr[nxt] < a[i]) se.insert(sg(nxt)); } for (int i = 0; ;i++) if (!se.count(i)) return f[x] = i; }
voidsol(){ memset(f, -1, sizeof f); cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < (1 << n); i++){ xr[i] = 0; for (int j = 0; j < n; j++) if (i & (1 << j)) xr[i] = xr[i] ^ a[j]; } if (sg((1 << n) - 1)) cout << "Left" << endl; else cout << "Right" << endl; }
signedmain(){ IO int t; cin >> t; while (t--) sol(); return0; }