// #include #include using namespace std; using namespace atcoder; using ll = long long; #define rep(i, n) for (int i=0; i<(int)(n); ++(i)) #define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i)) #define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i)) #define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i)) #define all(x) (x).begin(), (x).end() const int INF = (int)(1e9); const vector clst = { 'R', 'U', 'L', 'D' }; void r_roll(int& x1, int& y1, int& di1, int& x2, int& y2, int& di2) { swap(x1, y1), swap(x2, y2); y1 *= -1, y2 *= -1; di1 = (di1+3) % 4, di2 = (di2+3) % 4; } int main() { int t0; cin >> t0; rep(i0, t0) { int x1, y1, x2, y2; char d1, d2; cin >> x1 >> y1 >> d1 >> x2 >> y2 >> d2; int di1 = find(all(clst), d1) - clst.begin(), di2 = find(all(clst), d2) - clst.begin(), rlen = di1; rep(i, rlen) r_roll(x1, y1, di1, x2, y2, di2); if (di2 == 0) cout << "No" << endl; else if (di2 == 1) { if (x2 > x1 && x2-x1 == y1-y2) cout << "Yes" << endl; else cout << "No" << endl; } else if (di2 == 2) { if (y1 == y2 && x2 > x1) cout << "Yes" << endl; else cout << "No" << endl; } else { if (x2 > x1 && x2-x1 == y2-y1) cout << "Yes" << endl; else cout << "No" << endl; } } return 0; }