// コンパイルはctrl + shift + B #include #include using namespace std; using namespace atcoder; #define ll long long #define all(x) (x).begin(), (x).end() #define yes "Yes" #define no "No" // 最大公約数 O(log(N)) template T gcd(T a, T b) { if (b == 0) return a; else return gcd(b, a % b); } // 素数判定 O(sqrt(N)) bool is_prime(ll n) { for (ll i = 2; i*i <= n; i++) { if (n % i == 0) return false; } return true; } //n以下の素数求めマシーン O(Nloglog(N)) vector getprime(ll n) { vector ans; vector isprime(n + 1, true); //0, 1はダメ isprime[0] = false; isprime[1] = false; //やる for (int i = 2; i <= n; i++) { if (!isprime[i]) continue; ans.push_back(i); for (int j = 2 * i; j <= n; j += i) { //i以外のiの倍数をキャンセル isprime[j] = false; } } return ans; } // nを素因数分解 O(sqrt(N)) vector> prime_factorize(ll n) { vector> ans; for (ll i = 2; i*i <= n; i++) { if (n % i != 0) continue; ll e = 0; while (n % i == 0) { e++; n /= i; } ans.push_back({i, e}); } if (n != 1) ans.push_back({n, 1}); return ans; } // 各n以下の最小の素因数 O(NlogN) vector smallest_prime(ll n) { vector spf(n+1); for (ll i = 0; i <= n; i++) spf[i] = i; //初期化 for (ll i = 2; i+i <= n; i++) { if (spf[i] == i) { for (ll j = i*i; j <= n; j += i) { if (spf[j] == j) spf[j] = i; } } } return spf; } // 以下、コードを記すのである。 // using mint = modint998244353; using mint = modint1000000007; int main() { int t; cin >> t; while (t--) { vector> pos(2, vector(2)); vector c(2); for (int i = 0; i < 2; i++) { cin >> pos[i][0] >> pos[i][1] >> c[i]; } map mp; mp['U'] = 1; mp['D'] = 1; if (c[0] == c[1]) cout << no << endl; else { if (mp[c[0]] == mp[c[1]]) { if (pos[0][1-mp[c[0]]] != pos[1][1-mp[c[1]]]) cout << no << endl; else { if (c[0] == 'R') { if (pos[0][mp[c[0]]] < pos[1][mp[c[1]]]) cout << yes << endl; else cout << no << endl; } if (c[0] == 'L') { if (pos[0][mp[c[0]]] > pos[1][mp[c[1]]]) cout << yes << endl; else cout << no << endl; } if (c[0] == 'U') { if (pos[0][mp[c[0]]] < pos[1][mp[c[1]]]) cout << yes << endl; else cout << no << endl; } if (c[0] == 'D') { if (pos[0][mp[c[0]]] > pos[1][mp[c[1]]]) cout << yes << endl; else cout << no << endl; } } } else { if (pos[0][0] == pos[1][0] || pos[0][1] == pos[1][1]) cout << no << endl; else { int diffx = pos[1][0] - pos[0][0]; int diffy = pos[1][1] - pos[0][1]; if (abs(diffx) != abs(diffy)) cout << no << endl; else { if (c[0] == 'R' && diffx > 0) { if ((diffy > 0 && c[1] == 'D') || (diffy < 0 && c[1] == 'U')) { cout << yes << endl; } else cout << no << endl; } else if (c[0] == 'L' && diffx < 0) { if ((diffy > 0 && c[1] == 'D') || (diffy < 0 && c[1] == 'U')) { cout << yes << endl; } else cout << no << endl; } else if (c[0] == 'U' && diffy > 0) { if ((diffx > 0 && c[1] == 'L') || (diffx < 0 && c[1] == 'R')) { cout << yes << endl; } else cout << no << endl; } else if (c[0] == 'D' && diffy < 0) { if ((diffx > 0 && c[1] == 'L') || (diffx < 0 && c[1] == 'R')) { cout << yes << endl; } else cout << no << endl; } else cout << no << endl; } } } } } }