#include using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) using ll = long long; int ctoi(char c){return c-'0';} ll ctoll(char c){return c-'0';} int main(){ int t; cin >> t; rep(i,t){ int x1,y1; int x2,y2; char d1,d2; cin >> x1 >> y1 >> d1; cin >> x2 >> y2 >> d2; if(x1 > x2){ swap(x1,x2); swap(y1,y2); swap(d1,d2); } if(y1 == y2){ if(d1=='R' && d2=='L'){ cout << "Yes" << endl; }else{ cout << "No" << endl; } continue; } if(x1 == x2){ if(y1>y2){ if(d1=='D' && d2=='U'){ cout << "Yes" << endl; }else{ cout << "No" << endl; } }else{ if(d1=='U' && d2=='D'){ cout << "Yes" << endl; }else{ cout << "No" << endl; } } continue; } int tate = abs(y1-y2); int yoko = abs(x1-x2); if(tate==yoko){ if(y1>y2){ if((d1=='R' && d2=='U') || (d1=='D' && d2=='L')){ cout << "Yes" << endl; }else{ cout << "No" << endl; } }else{ if((d1=='R' && d2=='D') || (d1=='U' && d2=='L')){ cout << "Yes" << endl; }else{ cout << "No" << endl; } } continue; }else{ cout << "No" << endl; } } }