#include //#include using namespace std; //using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; //const int INF = 1e9; //const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n-1); i >= 0; --i) #define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define endl "\n" #define P pair template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } int calc(int x, int y, int p, int q, char d) { if (x != p && y != q)return -1; if (x == p) { if (y <= q && d == 'U') { return abs(y - q); } if (y >= q && d == 'D') { return abs(y - q); } } if (y == q) { if (x <= p && d == 'R') { return abs(x - p); } if (x >= p && d == 'L') { return abs(x - p); } } return -1; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while (t--) { int x0, y0; char d0; cin >> x0 >> y0 >> d0; int x1, y1; char d1; cin >> x1 >> y1 >> d1; if (d0 == d1) { cout << "No" << endl; continue; } if (x0 == x1) { if (y0 > y1) { swap(y0, y1); swap(d0, d1); } if (d0 == 'U' && d1 == 'D') cout << "Yes" << endl; else cout << "No" << endl; continue; } if (y0 == y1) { if (x0 > x1) { swap(x0, x1); swap(d0, d1); } if (d0 == 'R' && d1 == 'L') cout << "Yes" << endl; else cout << "No" << endl; continue; } { int x2 = x0; int y2 = y1; auto f0 = calc(x0, y0, x2, y2, d0); auto f1 = calc(x1, y1, x2, y2, d1); if (-1 != f0 && -1 != f1 && f0 == f1) { cout << "Yes" << endl; continue; } } { int x2 = x1; int y2 = y0; auto f0 = calc(x0, y0, x2, y2, d0); auto f1 = calc(x1, y1, x2, y2, d1); if (-1 != f0 && -1 != f1 && f0 == f1) { cout << "Yes" << endl; continue; } } cout << "No" << endl; } return 0; }