#include using namespace std; int main() { int T; cin >> T; while (T--) { long long x1, y1; char d1; cin >> x1 >> y1 >> d1; long long x2, y2; char d2; cin >> x2 >> y2 >> d2; string S; S += d1; S += d2; map mp; mp['R'] = 1; mp['L'] = -1; mp['U'] = 1; mp['D'] = -1; if (S == "RL" || S == "LR") { if (y1 == y2) { if (x1 < x2) { if (d1 == 'R' && d2 == 'L') { cout << "Yes" << endl; continue; } } else { if (d1 == 'L' && d2 == 'R') { cout << "Yes" << endl; continue; } } } } if (S == "UD" || S == "DU") { if (x1 == x2) { if (y1 < y2) { if (d1 == 'U' && d2 == 'D') { cout << "Yes" << endl; continue; } } else { if (d1 == 'D' && d2 == 'U') { cout << "Yes" << endl; continue; } } } } if (S == "RL" || S == "LR") { long long l = min(x1, x2), r = max(x1, x2); long long mid = l + (r - l) / 2; long long dx1 = abs(x1 - mid); // long long dx2 = abs(x2 - mid); x1 = x1 + dx1 * mp[d1]; x2 = x2 + dx1 * mp[d2]; if (x1 == x2 && y1 == y2) { cout << "Yes" << endl; continue; } } if (S == "UD" || S == "DU") { long long l = min(y1, y2), r = max(y1, y2); long long mid = l + (r - l) / 2; long long dy1 = abs(y1 - mid); // long long dy2 = abs(y2 - mid); y1 = y1 + dy1 * mp[d1]; y2 = y2 + dy1 * mp[d2]; if (x1 == x2 && y1 == y2) { cout << "Yes" << endl; continue; } } if (S == "RU" || S == "RD" || S == "LU" || S == "LD") { long long xx = x2, yy = y1; long long dx = abs(x1 - xx); long long dy = abs(y2 - yy); x1 = x1 + dx * mp[d1]; y2 = y2 + dy * mp[d2]; if (x1 == x2 && y1 == y2) { cout << "Yes" << endl; continue; } } if (S == "UR" || S == "UL" || S == "DR" || S == "DL") { long long xx = x1, yy = y2; long long dx = abs(x2 - xx); long long dy = abs(y1 - yy); x2 = x2 + dx * mp[d2]; y1 = y1 + dy * mp[d1]; if (x1 == x2 && y1 == y2) { cout << "Yes" << endl; continue; } } cout << "No" << endl; } return 0; }