#include int h[100005], l; int comp_h(int a, int b) { if (h[a] > h[b]) return 1; else return -1; } void swap_h(int a, int b) { int f = h[a]; h[a] = h[b]; h[b] = f; return; } void push(int ne) { h[l] = ne; int p = l++; for (; p > 0; p = (p - 1) / 2) if (comp_h((p - 1) / 2, p) > 0) swap_h((p - 1) / 2, p); return; } int pop() { swap_h(0, --l); int p = 0; for (;;) { if (2 * p + 2 < l) { if (comp_h(2 * p + 1, 2 * p + 2) > 0) { if (comp_h(p, 2 * p + 2) > 0) swap_h(p, 2 * p + 2); p = 2 * p + 2; } else { if (comp_h(p, 2 * p + 1) > 0) swap_h(p, 2 * p + 1); p = 2 * p + 1; } } else if (2 * p + 1 < l) { if (comp_h(p, 2 * p + 1) > 0) swap_h(p, 2 * p + 1); p = 2 * p + 1; } else break; } return h[l]; } int x[100005], y[100005]; char c[100005]; char st[8]; int s[100005]; void solve() { int n; scanf("%d", &n); n *= 2; int i; for (i = 0; i < n; i++) { scanf("%d %d %s", &x[i], &y[i], st); c[i] = st[0]; } int cx, cy; cx = cy = 0; for (i = 0; i < n; i++) { if (c[i] == 'x') cx++; else cy++; } int d; l = 0; if (cx > cy) { d = cx - cy; for (i = 0; i < n; i++) if (c[i] == 'x') push(y[i]); n = cx; for (i = 0; i < n; i++) s[i] = pop(); } else { d = cy - cx; for (i = 0; i < n; i++) if (c[i] == 'y') push(x[i]); n = cy; for (i = 0; i < n; i++) s[i] = pop(); } for (i = 0; i < n; i++) { if (s[i] == s[i + 1]) { d -= 2; i++; } } if (d > 0) printf("No\n"); else printf("Yes\n"); return; } int main() { int t; scanf("%d", &t); for (; t > 0; t--) solve(); return 0; }