import std, core.bitop; string[] _R; void readM(T)(ref T x) { if (_R.empty) { _R = readln.chomp.split; } x = _R.front.to!T; _R.popFront; } bool chmin(T)(ref T A, T B) { if (A > B) { A = B; return true; } else { return false; } } bool chmax(T)(ref T A, T B) { if (A < B) { A = B; return true; } else { return false; } } int lowerBound(T)(T[] A, T x) { int lo = -1, hi = cast(int)(A.length); while (hi - lo > 1) { int mid = lo + hi >> 1; (A[mid] < x ? lo : hi) = mid; } return hi; } int upperBound(T)(T[] A, T x) { int lo = -1, hi = cast(int)(A.length); while (hi - lo > 1) { int mid = lo + hi >> 1; (A[mid] > x ? hi : lo) = mid; } return hi; } void main() { int TE; TE.readM; enum dx = [-1, 1, 0, 0]; enum dy = [0, 0, 1, -1]; int[256] A; A['L'] = 0; A['R'] = 1; A['U'] = 2; A['D'] = 3; long f(long x, long X1, long Y1, char D1, long X2, long Y2, char D2) { long a = X1, b = Y1, c = X2, d = Y2; a += x * dx[A[D1]]; b += x * dy[A[D1]]; c += x * dx[A[D2]]; d += x * dy[A[D2]]; return abs(a - c) + abs(b - d); } foreach (_; 0 .. TE) { long X1, Y1, X2, Y2; char D1, D2; X1.readM; Y1.readM; D1.readM; X2.readM; Y2.readM; D2.readM; X1 *= 2; Y1 *= 2; X2 *= 2; Y2 *= 2; long lo = 1, hi = 10L ^^ 10; while (hi - lo > 2) { long mid1 = (lo + lo + hi) / 3; long mid2 = (lo + hi + hi) / 3; if (f(mid1, X1, Y1, D1, X2 ,Y2, D2) > f(mid2, X1, Y1, D1, X2, Y2, D2)) lo = mid1; else hi = mid2; } bool ans = false; foreach (i; lo .. hi + 1) { ans = ans || !f(i, X1, Y1, D1, X2, Y2, D2); } writeln(ans ? "Yes" : "No"); } }