#include using namespace std; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; int index(char dir) { if (dir == 'R') return 0; else if (dir == 'U') return 1; else if (dir == 'L') return 2; else return 3; } int main() { int T; cin >> T; for (int t = 0; t < T; t++) { // input int x1, x2, y1, y2; char d1, d2; cin >> x1 >> y1 >> d1; cin >> x2 >> y2 >> d2; // main string ans; if (x1 == x2) { if (y1 < y2 && d1 == 'U' && d2 == 'D' && abs(y1 - y2) % 2 == 0) ans = "Yes"; else if (y1 > y2 && d1 == 'D' && d2 == 'U' && abs(y1 - y2) % 2 == 0) ans = "Yes"; else ans = "No"; } else if (y1 == y2) { if (x1 < x2 && d1 == 'R' && d2 == 'L') ans = "Yes"; else if (x1 > x2 && d1 == 'L' && d2 == 'R') ans = "Yes"; else ans = "No"; } else { int d_idx1 = index(d1), d_idx2 = index(d2); int tx = abs(x1 - x2), ty = abs(y1 - y2); if (tx == ty) { long long cx1, cx2, cy1, cy2; cx1 = x1 + tx * dx[d_idx1]; cy1 = y1 + ty * dy[d_idx1]; cx2 = x2 + tx * dx[d_idx2]; cy2 = y2 + ty * dy[d_idx2]; // cout << cx1 << ", " << cy1 << endl; // cout << cx2 << ", " << cy2 << endl; if (cx1 == cx2 && cy1 == cy2) ans = "Yes"; else ans = "No"; } else ans = "No"; } // output cout << ans << endl; } }