/*               ∧∧∩               ( ゚∀゚)/ キタ━━━━━━(゚∀゚)━━━━━━!!!!             ⊂   ノ  ゆっくり見てってね!!!!!!!!              (つ ノ     o          (ノ      \      ☆              |      o           (⌒ ⌒ヽ   /     ☆     \  (´⌒  ⌒  ⌒ヾ   /       ('⌒ ; ⌒   ::⌒  )      (´     )     ::: ) /   ☆─ (´⌒;:    ::⌒`) :;  ) */ #include #include using namespace std; using namespace atcoder; #define elif else if #define rep(i, s, n) for (int i=s; i>i)&1) typedef long long ll; typedef long double ld; ld pi = 3.14159265358979; inline void scan(){} template inline void scan(Head&head,Tail&... tail){std::cin>>head;scan(tail...);} // print(a, b, c) => cout << a << ' ' << b << ' ' << c << endl; inline void print(){} template inline void print(Head&head,Tail&... tail){std::cout< std::istream &operator>>(std::istream&is,std::vector&v){for(T &in:v){is>>in;}return is;} template std::ostream &operator<<(std::ostream&os,const std::vector&v){for(auto it=std::begin(v);it!=std::end(v);){os<<*it<<((++it)!=std::end(v)?" ":"");}return os;} // 2地点の距離(long double) long double coor_dist(long double xi, long double yi, long double xj, long double yj) { return sqrt(abs((xi - xj) * (xi - xj)) + abs((yi - yj) * (yi - yj))); } // 回文かどうかの判定 bool iskaibun(string s){ll k = s.size();rep(i,0,k/2){if(s[i]!=s[k-1-i]){return false;}}return true;} template void chmax(T& a, T b) { if (a < b) a = b; } template void chmin(T& a, T b) { if (a > b) a = b; } #define mod 998244353 using mint = modint998244353; int op(int a, int b) {return max(a, b);} int e() {return 0;} int mapping(int f, int x) {return (f == 1e9 ? x : f);} int composition(int f, int g) {return (f == 1e9 ? g : f);} int id() {return 1e9;} #include using namespace std; // rollback できる UnionFind木 struct upd { int& a; int x; upd(int &a): a(a), x(a) {} }; using Hist = vector; struct UnionFind { int ans; vector d, e; UnionFind(int n=0): ans(0), d(n,-1), e(n,0) {} int root(int x) { if (d[x] < 0) return x; return root(d[x]); } int f(int v) { return min(size(v), e[v]); } void unite(int x, int y) { x = root(x); y = root(y); hist.push_back(Hist()); Hist& h = hist.back(); h.emplace_back(ans); if (x == y) { h.emplace_back(e[x]); e[x]++; if (e[x] == size(x)) ans++; } else { if (size(x) < size(y)) swap(x,y); h.emplace_back(d[x]); h.emplace_back(d[y]); h.emplace_back(e[x]); ans -= f(x); ans -= f(y); d[x] += d[y]; d[y] = x; e[x] += e[y]+1; ans += f(x); } } vector hist; void rollback() { for (auto [a,x] : hist.back()) a = x; hist.pop_back(); } int size(int x) { return -d[root(x)]; } bool same(int u, int v) { return root(u) == root(v); } }; signed main() { cin.tie(nullptr); cout << fixed << setprecision(10); ios::sync_with_stdio(false); int t; cin >> t; auto f = [&](auto&& f, int i) -> void { if(!i) cout << "No" << endl; else cout << "Yes" << endl; return ; }; auto g = [&](auto&& g, vector x, vector y, vector d) -> void { int a, b; if(d[0] == 'R' || d[0] == 'L') a = 1; if(d[1] == 'R' || d[1] == 'L') b = 1; if(d[0] == 'U' || d[0] == 'D') a = 2; if(d[1] == 'U' || d[1] == 'D') b = 2; if(a == b && a == 1) { if(y[0] != y[1]) f(f, 0); else f(f, 1); } elif(a == b && a == 2) { if(x[0] != x[1]) f(f, 0); else f(f, 1); } elif(a == 1) { int gx = x[1]; int gy = y[0]; int sax = gx-x[0]; int say = gy-y[1]; if(d[0] == 'L') sax *= -1; if(d[1] == 'D') say *= -1; if(sax < 0 || say < 0 || sax != say) f(f, 0); else f(f, 1); } else { int gx = x[0]; int gy = y[1]; int sax = gx-x[1]; int say = gy-y[0]; if(d[1] == 'L') sax *= -1; if(d[0] == 'D') say *= -1; if(sax < 0 || say < 0 || sax != say) f(f, 0); else f(f, 1); } }; while(t--) { vector x(2), y(2); vector d(2); cin >> x[0] >> y[0] >> d[0]; cin >> x[1] >> y[1] >> d[1]; g(g, x, y, d); } }