#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long int ll; typedef pair Pii; const ll mod = 998244353; struct problem { int x1, y1; char d1; int x2, y2; char d2; }; int main() { cin.tie(0); ios::sync_with_stdio(false); int t; cin >> t; vector problems(t); for (auto &p: problems) { cin >> p.x1 >> p.y1 >> p.d1; cin >> p.x2 >> p.y2 >> p.d2; } vector ans(t); for (int i = 0; i < t; i++) { auto p = problems[i]; if (p.d1 == p.d2) { ans[i] = "No"; } else if (p.d1 == 'R' && p.d2 == 'L') { ans[i] = (p.y1 == p.y2 && p.x1 < p.x2) ? "Yes" : "No"; } else if (p.d1 == 'L' && p.d2 == 'R') { ans[i] = (p.y1 == p.y2 && p.x1 > p.x2) ? "Yes" : "No"; } else if (p.d1 == 'U' && p.d2 == 'D') { ans[i] = (p.x1 == p.x2 && p.y1 < p.y2) ? "Yes" : "No"; } else if (p.d1 == 'D' && p.d2 == 'U') { ans[i] = (p.x1 == p.x2 && p.y1 > p.y2) ? "Yes" : "No"; } else if ((p.d1 == 'R' && p.d2 == 'U') || (p.d1 == 'D' && p.d2 == 'L')) { ans[i] = (p.x1 + p.y1 == p.x2 + p.y2 && p.x1 < p.x2) ? "Yes" : "No"; } else if ((p.d1 == 'L' && p.d2 == 'D') || (p.d1 == 'U' && p.d2 == 'R')) { ans[i] = (p.x1 + p.y1 == p.x2 + p.y2 && p.x1 > p.x2) ? "Yes" : "No"; } else if ((p.d1 == 'R' && p.d2 == 'D') || (p.d1 == 'U' && p.d2 == 'L')) { ans[i] = (p.x1 - p.y1 == p.x2 - p.y2 && p.x1 < p.x2) ? "Yes" : "No"; } else if ((p.d1 == 'L' && p.d2 == 'U') || (p.d1 == 'D' && p.d2 == 'R')) { ans[i] = (p.x1 - p.y1 == p.x2 - p.y2 && p.x1 > p.x2) ? "Yes" : "No"; } } for (auto &x: ans) cout << x << endl; return 0; }