#include using namespace std; using ld = long double; using P = pair; int main() { int t; cin >> t; auto calc = [&](P p, P q, P r, P s) { auto [a, c] = p; auto [b, d] = q; auto [e, g] = r; auto [f, h] = s; if (b == f && d == h) { return a == e && c == g; } else if (b == f) { return a == e; } else if (d == h) { return c == g; } else { return ((a - e) / (f - b)) == ((c - g) / (h - d)); } }; map mp; mp['R'] = {1, 0}; mp['L'] = {-1, 0}; mp['U'] = {0, 1}; mp['D'] = {0, -1}; while (t--) { ld x1, y1, x2, y2; char d1, d2; cin >> x1 >> y1 >> d1 >> x2 >> y2 >> d2; cout << (calc({x1, y1}, mp[d1], {x2, y2}, mp[d2]) ? "Yes" : "No") << endl; } }