#include #include #include #include using namespace std; void solve() { int n; cin >> n; vector x(2 * n), y(2 * n); vector c(2 * n); for (int i = 0; i < 2 * n; ++i) cin >> x[i] >> y[i] >> c[i]; map sx, sy; for (int i = 0; i < 2 * n; ++i) { if (c[i] == 'x') { ++sy[y[i]]; } else if (c[i] == 'y') { ++sx[x[i]]; } } int mx = 0, cx = 0; for (auto [xx, c] : sx) { mx += c % 2; cx += c; } int my = 0, cy = 0; for (auto [yy, c] : sy) { my += c % 2; cy += c; } if (cx < cy) { swap(cx, cy); swap(mx, my); } int ans = (mx <= cy && cy <= cx); cout << (ans ? "Yes" : "No") << endl; } int main() { int t; cin >> t; while (t--) solve(); }