#include using namespace std; #include using namespace atcoder; using ll = long long; using vi = vector; using vvi = vector>; using pii = pair; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define repr(i, n) for (int i = (int)(n - 1); i >= 0; --i) bool query() { int n; cin >> n; vi cnt(3); vector c(3, vector(n, false)); rep(i, n) { char ch; int x; cin >> ch >> x, x--; c[ch % 3][x] = true; cnt[ch % 3]++; } int con01 = 0, con02 = 0, con12 = 0, con123 = 0; rep(i, n) { if (c[0][i] && c[1][i] && c[2][i]) { if (con123 > 0) return true; con123 |= 1; } else { if (c[0][i] && c[1][i]) con01 |= 1; if (c[0][i] && c[2][i]) con02 |= 1; if (c[1][i] && c[2][i]) con12 |= 1; } if (con01 + con02 + con12 + con123 >= 2) return true; } if (con01 > 0) return cnt[2] == 0; if (con02 > 0) return cnt[1] == 0; if (con12 > 0) return cnt[0] == 0; if (con123 > 0) { if (cnt[0] == 1) return true; if (cnt[1] == 1) return true; if (cnt[2] == 1) return true; } int nz = 0; rep(i, 3) { if (cnt[i] > 0) nz++; } return nz == 1; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int t; cin >> t; while (t--) { cout << (query() ? "Yes" : "No") << '\n'; } return 0; }