#include using namespace std; using ll = long long; template ostream& operator << (ostream& os, const vector& vec) { if(vec.empty()) return os; os << vec[0]; for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it; return os; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; while(T--){ ll x1, y1, x2, y2; char c1, c2; cin >> x1 >> y1 >> c1 >> x2 >> y2 >> c2; if(c1 == c2){ cout << "No\n"; continue; } if((c1 == 'L' && c2 == 'R') || (c1 == 'R' && c2 == 'L')){ if(c2 == 'R'){ swap(x1, x2); swap(y1, y2); swap(c1, c2); } cout << (x1 < x2 && y1 == y2 ? "Yes" : "No") << '\n'; continue; } if((c1 == 'U' && c2 == 'D') || (c1 == 'D' && c2 == 'U')){ if(c2 == 'U'){ swap(x1, x2); swap(y1, y2); swap(c1, c2); } cout << (y1 < y2 && x1 == x2 ? "Yes" : "No") << '\n'; continue; } if(c2 == 'L' || c2 == 'R'){ swap(x1, x2); swap(y1, y2); swap(c1, c2); } if(c1 == 'L' && c2 == 'U'){ if(x2 < x1 && y2 < y1){ cout << (abs(x1 - x2) == abs(y1 - y2) ? "Yes" : "No") << '\n'; }else{ cout << "No\n"; } continue; } if(c1 == 'L' && c2 == 'D'){ if(x2 < x1 && y2 > y1){ cout << (abs(x1 - x2) == abs(y1 - y2) ? "Yes" : "No") << '\n'; }else{ cout << "No\n"; } continue; } if(c1 == 'R' && c2 == 'U'){ if(x2 > x1 && y2 < y1){ cout << (abs(x1 - x2) == abs(y1 - y2) ? "Yes" : "No") << '\n'; }else{ cout << "No\n"; } continue; } if(c1 == 'R' && c2 == 'D'){ if(x2 > x1 && y2 > y1){ cout << (abs(x1 - x2) == abs(y1 - y2) ? "Yes" : "No") << '\n'; }else{ cout << "No\n"; } continue; } } }