#include using namespace std; using ll = long long; void NO(){cout << "No" << endl;} void YES(){cout << "Yes" << endl;} void solve(){ char c1, c2; int x1, y1, x2, y2; cin >> x1 >> y1 >> c1 >> x2 >> y2 >> c2; if (c1 > c2){ swap(x1, x2); swap(y1, y2); swap(c1, c2); } if (c1 == 'D' && c2 == 'U' && x1 == x2 && y1 > y2) YES(); else if (c1 == 'L' && c2 == 'R' && y1 == y2 && x1 > x2) YES(); else if (c1 == 'D' && c2 == 'R' && x1 > x2 && y1-y2 == x1-x2) YES(); else if (c1 == 'D' && c2 == 'L' && x1 < x2 && y1-y2 == x2-x1) YES(); else if (c1 == 'L' && c2 == 'U' && x1 > x2 && y1-y2 == x1-x2) YES(); else if (c1 == 'R' && c2 == 'U' && x1 < x2 && y1-y2 == x2-x1) YES(); else NO(); } int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int T; cin >> T; while(T--){ solve(); } return 0; }