#pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; using ld = long double; const vector dx = {0, 0, 1, -1}; const vector dy = {1, -1, 0, 0}; #define vec vector #define int long long #define double long double //cout< #define pq priority_queue #define all(V) begin(V),end(V) #define printpair(p) cout< template inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; } #define mend(a,b) G[a].push_back(b) signed main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int t;cin>>t; rep(i,t){ int a,b; char c; cin>>a>>b>>c; int x,y; char z; cin>>x>>y>>z; if(x==a&&(y>b&&z=='D'&&c=='U')){ cout<<"Yes\n";continue; } if(x==a&&(b>y&&c=='D'&&z=='U')){ cout<<"Yes\n";continue; } if(y==b&&(x>a&&z=='L'&&c=='R')){ cout<<"Yes\n";continue; } if(y==b&&(xx&&b>y){ if(c=='L'&&z=='U'){ cout<<"Yes\n";continue; } if(c=='D'&&z=='R'){ cout<<"Yes\n";continue; } } if(a>x&&by){ if(c=='U'&&z=='R'){ cout<<"Yes\n";continue; } if(c=='L'&&z=='D'){ cout<<"Yes\n";continue; } } } cout<<"No\n"; } }