#include using namespace std; template using min_priority_queue = priority_queue,greater>; template void printv(vector &v){ bool b = false; for(auto i : v){ if(b) cout << " "; else b = true; cout << i; } cout << endl; } template bool chmin(T &a, const T& b) { if (a > b) { a = b; // aをbで更新 return true; } return false; } template bool chmax(T &a, const T& b) { if (a < b) { a = b; // aをbで更新 return true; } return false; } void yn(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; } bool debug; bool randomInput; void input(){ if(debug && randomInput){ } else{ } return; } void calc(){ vector> dir = {{1,0},{0,1},{-1,0},{0,-1}}; map mp; mp['D'] = 0; mp['R'] = 1; mp['U'] = 2; mp['L'] = 3; int T; cin >> T; for(int i = 0; i < T; i++){ int x1, y1; int x2, y2; char d1, d2; cin >> x1 >> y1 >> d1; cin >> x2 >> y2 >> d2; swap(x1, y1); swap(x2, y2); x1 *= -1; x2 *= -1; int a1 = mp[d1]; int a2 = mp[d2]; if(d1 == d2){ cout << "No" << endl; continue; } if(a1 > a2){ swap(x1, x2); swap(y1, y2); swap(a1, a2); } if(a1%2 == 1 && a2%2 == 1){ if(x1 != x2){ cout << "No" << endl; } else if(y1 < y2) { cout << "Yes" << endl; } else{ cout << "No" << endl; } continue; } if(a1%2 == 0 && a2%2 == 0){ if(y1 != y2){ cout << "No" << endl; } else if(x1 < x2){ cout << "Yes" << endl; } else{ cout << "No" << endl; } continue; } if(a1 == 0 && a2 == 1){ int l1 = x2-x1; int l2 = y1-y2; if(l1 == l2 && l1 > 0){ cout << "Yes" << endl; } else{ cout << "No" << endl; } continue; } if(a1 == 0 && a2 == 3){ int l1 = x2-x1; int l2 = y2-y1; if(l1 == l2 && l1 > 0){ cout << "Yes" << endl; } else{ cout << "No" << endl; } continue; } if(a1 == 1 && a2 == 2){ int l1 = y2-y1; int l2 = x2-x1; if(l1 == l2 && l1 > 0){ cout << "Yes" << endl; } else{ cout << "No" << endl; } continue; } if(a1 == 2 && a2 == 3){ int l1 = x1-x2; int l2 = y2-y1; if(l1 == l2 && l1 > 0){ cout << "Yes" << endl; } else{ cout << "No" << endl; } continue; } } return; } int64_t ansSimple; void calcSimple(){ return; } void calc1(){ int t; cin >> t; for(int i = 0; i < t; i++){ input(); calc(); calcSimple(); } } int main(){ debug = 0; randomInput = 0; srand(time(NULL)); cout << fixed << setprecision(12); if(debug){ calc1(); } else{ input(); calc(); } return 0; } //