#include #include using namespace std; using namespace atcoder; using ll = long long; int T; int main(void){ cin >> T; for (int i = 0; i < T; i++) { int x1, y1, x2, y2; char d1, d2; cin >> x1 >> y1 >> d1; cin >> x2 >> y2 >> d2; if (d1 == d2) cout << "No" << endl; else { if (d1 == 'R' and d2 == 'L') { if (y1 == y2 and x1 < x2) cout << "Yes" << endl; else cout << "No" << endl; } else if (d1 == 'L' and d2 == 'R') { if (y1 == y2 and x1 > x2) cout << "Yes" << endl; else cout << "No" << endl; } else if (d1 == 'U' and d2 == 'D') { if (x1 == x2 and y1 < y2) cout << "Yes" << endl; else cout << "No" << endl; } else if (d1 == 'D' and d2 == 'U') { if (x1 == x2 and y1 > y2) cout << "Yes" << endl; else cout << "No" << endl; } else if (d1 == 'R' and d2 == 'U') { if (x1 < x2 and y1 > y2 and y1 - y2 == x2 - x1) cout << "Yes" << endl; else cout << "No" << endl; } else if (d1 == 'R' and d2 == 'D') { if (x1 < x2 and y1 < y2 and y2 - y1 == x2 - x1) cout << "Yes" << endl; else cout << "No" << endl; } else if (d1 == 'L' and d2 == 'U') { if (x1 > x2 and y1 > y2 and y1 - y2 == x1 - x2) cout << "Yes" << endl; else cout << "No" << endl; } else if (d1 == 'L' and d2 == 'D') { if (x1 > x2 and y1 > y2 and y1 - y2 == x1 - x2) cout << "Yes" << endl; else cout << "No" << endl; } else if (d1 == 'U' and d2 == 'R') { if (x1 > x2 and y1 < y2 and y2 - y1 == x1 - x2) cout << "Yes" << endl; else cout << "No" << endl; } else if (d1 == 'U' and d2 == 'L') { if (x1 < x2 and y1 < y2 and y2 - y1 == x2 - x1) cout << "Yes" << endl; else cout << "No" << endl; } else if (d1 == 'D' and d2 == 'R') { if (x1 > x2 and y1 > y2 and y1 - y2 == x1 - x2) cout << "Yes" << endl; else cout << "No" << endl; } else if (d1 == 'D' and d2 == 'L') { if (x1 < x2 and y1 > y2 and y1 - y2 == x2 - x1) cout << "Yes" << endl; else cout << "No" << endl; } } } return 0; }