#include //#include using namespace std; //using namespace atcoder; using ll = long long; const int INF = 1000000007; //const ll mod = 998244353; int t, x[100009][5], y[100009][5]; char d[100009][5]; int main() { cin >> t; for (int i = 1; i <= t; i++) { for (int j = 1; j <= 2; j++)cin >> x[i][j] >> y[i][j] >> d[i][j]; } for (int i = 1; i <= t; i++) { if (d[i][1] == d[i][2]) { cout << "No" << endl; continue; } setS; S.insert(d[i][1]); S.insert(d[i][2]); if ((S.count('R') == 1 && S.count('L') == 1) || (S.count('U') == 1 && S.count('D') == 1)) { if (S.count('R') == 1) { if (y[i][1] == y[i][2]) { if (d[i][1] == 'L') { if (x[i][1] > x[i][2])cout << "Yes" << endl; else cout << "No" << endl; } if (d[i][2] == 'L') { if (x[i][2] > x[i][1])cout << "Yes" << endl; else cout << "No" << endl; } } else cout << "No" << endl; } if (S.count('U') == 1) { if (x[i][1] == x[i][2]) { if (d[i][1] == 'U') { if (y[i][1] < y[i][2])cout << "Yes" << endl; else cout << "No" << endl; } if (d[i][2] == 'U') { if (y[i][2] < y[i][1])cout << "Yes" << endl; else cout << "No" << endl; } } else cout << "No" << endl; } continue; } if (d[i][1] == 'R' || d[i][1] == 'L') { swap(d[i][1], d[i][2]); swap(x[i][1], x[i][2]); swap(y[i][1], y[i][2]); } int x1 = x[i][1], y2 = y[i][2]; int d1 = 0, d2 = 0; if (d[i][1] == 'U')d1 = y2 - y[i][1]; else d1 = y[i][1] - y2; if (d[i][2] == 'L')d2 = x[i][2] - x1; else d2 = x1 - x[i][2]; if (d1 == d2 && d1 > 0)cout << "Yes" << endl; else cout << "No" << endl; } }