#include #include #include #include #include #include #include #include #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; using namespace atcoder; using ll = long long; using p = pair; using mod = modint998244353; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } vector> RunLength(string s){ vector> R; int n = s.size(); int pre = 0; rep(i,n - 1){ if(s[i + 1] != s[i]){ R.push_back({s[i],i - pre + 1}); pre = i + 1; } } if(pre != n)R.push_back({s[n - 1],n - pre}); return R; } int op(int a,int b){return min(a,b);} int e(){return (int)1e9;} segtree seg(1); int n,m; map> mp; int bfs(int start,int goal){ queue Q; vector seen(n,-1); Q.push(start); seen[start] = 0; while(Q.size()){ int now = Q.front();Q.pop(); for(int next:mp[now]){ if(seen[next] != -1)continue; seen[next] = seen[now] + 1; Q.push(next); if(next == goal)Q = {}; } } return seen[goal]; } int main(){ int t;cin >> t; while(t--){ int x1,x2,y1,y2; char d1,d2; cin >> x1 >> y1 >> d1; cin >> x2 >> y2 >> d2; if(d1 == d2){ cout << "No" << endl; }else if((d1 == 'U' && d2 == 'D') || (d1 == 'D' && d2 == 'U') || (d1 == 'L' && d2 == 'R') || (d1 == 'R' && d2 == 'L')){ string ans = "No"; if(d1 == 'L' && d2 == 'R' && y1 == y2 && x2 <= x1)ans = "Yes"; if(d1 == 'R' && d2 == 'L' && y1 == y2 && x2 >= x1)ans = "Yes"; if(d1 == 'U' && d2 == 'D' && x1 == x2 && y2 >= y1)ans = "Yes"; if(d1 == 'D' && d2 == 'U' && x1 == x2 && y2 <= y1)ans = "Yes"; cout << ans << endl; }else{ vector L{0,0}; int k1,k2; if(d1 == 'R' || d1 == 'L'){ L[0] = x2; L[1] = y1; k1 = L[0] - x1; k2 = L[1] - y2; if(d1 == 'L')k1 *= -1; if(d2 == 'D')k2 *= -1; }else{//d1 U or D L[0] = x1; L[1] = y2; k1 = L[1] - y1; k2 = L[0] - x2; if(d1 == 'D')k1 *= -1; if(d2 == 'L')k2 *= -1; } if(k1 >= 0 && k1 == k2){ cout << "Yes" << endl; }else{ cout << "No" << endl; } } } }