/* -*- coding: utf-8 -*- * * 2564.cc: No.2564 衝突予測 - yukicoder */ #include #include using namespace std; /* constant */ /* typedef */ /* global variables */ /* subroutines */ /* main */ int main() { int tn; scanf("%d", &tn); while (tn--) { int x0, y0, x1, y1; char s0[4], s1[4]; scanf("%d%d%s%d%d%s", &x0, &y0, s0, &x1, &y1, s1); char c0 = s0[0], c1 = s1[0]; if ((y0 == y1 && ((x0 < x1 && c0 == 'R' && c1 == 'L') || (x0 > x1 && c0 == 'L' && c1 == 'R'))) || (x0 == x1 && ((y0 < y1 && c0 == 'U' && c1 == 'D') || (y0 > y1 && c0 == 'D' && c1 == 'U')))) puts("Yes"); else if ((c0 == 'L' || c0 == 'R') && (c1 == 'U' || c1 == 'D')) { int d0 = (c0 == 'L') ? x0 - x1 : x1 - x0; int d1 = (c1 == 'U') ? y0 - y1 : y1 - y0; if (d0 > 0 && d1 > 0 && d0 == d1) puts("Yes"); else puts("No"); } else if ((c0 == 'U' || c0 == 'D') && (c1 == 'L' || c1 == 'R')) { int d0 = (c0 == 'D') ? y0 - y1 : y1 - y0; int d1 = (c1 == 'R') ? x0 - x1 : x1 - x0; if (d0 > 0 && d1 > 0 && d0 == d1) puts("Yes"); else puts("No"); } else puts("No"); } return 0; }