#include #include #define chmin(x,y) (x) = min((x),(y)) #define chmax(x,y) (x) = max((x),(y)) #define ld long double using namespace std; using namespace atcoder; using ll = long long; const ll mod = 998244353; using mint = modint998244353; using Graph = vector>; const vector dx = {1,0,-1,0}, dy = {0,1,0,-1}; int main(){ int T; cin >> T; while(T--){ // input int x1,x2,y1,y2; char d1,d2; cin >> x1 >> y1 >> d1; cin >> x2 >> y2 >> d2; // prep if(d1 > d2){ swap(x1,x2); swap(y1,y2); swap(d1,d2); } // solve bool crash = 0; if(d1 == 'L' && d2 == 'R' && y1 == y2 && x1 > x2) crash = 1; else if(d1 == 'D' && d2 == 'U' && x1 == x2 && y1 > y2) crash = 1; else{ int X,Y,t1,t2; if(d1 == 'D'){ X = x1, Y = y2; t1 = y1-Y, t2 = (X-x2) * (d2 == 'R' ? 1 : -1) ; } else { // then d2 == 'U' and d1 == 'L'/'R' X = x2, Y = y1; t1 = (X-x1) * (d1 == 'R' ? 1 : -1), t2 = Y-y2; } if(t1 == t2 && t1 > 0) crash = 1; //cout << X << " " << Y << " " << t1 << " " << t2 << endl; } // output cout << (crash ? "Yes" : "No") << endl; } }