#include #include #include #include #include #include #include using namespace std; string s = "URDL"; bool solve() { int x1, y1; cin >> x1 >> y1; char dd1; cin >> dd1; int d1, d2; int x2, y2; cin >> x2 >> y2; char dd2; cin >> dd2; for (int k = 0; k < 4; k++) { if (dd1 == s[k]) { d1 = k; } if (dd2 == s[k]) { d2 = k; } } if (d1 == d2) { return false; } if (d1 == 0 and d2 == 2 and x1 == x2 and y1 < y2) { return true; } if (d1 == 1 and d2 == 3 and y1 == y2 and x1 < x2) { return true; } if (d1 == 0 and d2 == 1 and y2 - y1 == x1 - x2) return true; if (d1 == 0 and d2 == 3 and y2 - y1 == x2 - x1) return true; if (d1 == 1 and d2 == 2 and x2 - x1 == y2 - y1) return true; if (d1 == 2 and d2 == 3 and x2 - x1 == y1 - y2) return true; swap(d1, d2), swap(x1, x2), swap(y1, y2); if (d1 == 0 and d2 == 2 and x1 == x2 and y1 < y2) { return true; } if (d1 == 1 and d2 == 3 and y1 == y2 and x1 < x2) { return true; } if (d1 == 0 and d2 == 1 and y2 - y1 == x1 - x2) return true; if (d1 == 0 and d2 == 3 and y2 - y1 == x2 - x1) return true; if (d1 == 1 and d2 == 2 and x2 - x1 == y2 - y1) return true; if (d1 == 2 and d2 == 3 and x2 - x1 == y1 - y2) return true; return false; } int main() { int t; cin >> t; while (t--) { if (solve()) { cout << "Yes" << endl; } else { cout << "No" << endl; } } }