You are given a directed grid graph with rows and columns. Its vertices are denoted by , where and .
For every pair of orthogonally adjacent vertices, there is exactly one directed edge between them. In other words, exactly one of the two possible directions is chosen for every horizontally or vertically adjacent pair.
For four integers satisfying and , the represented by them is the induced subgraph consisting of the following vertices and all edges between them:
The given graph contains at least one directed cycle. Among all subrectangles containing a directed cycle, find one minimizing the area
If several subrectangles have the minimum area, choose the one for which is lexicographically smallest.
The input is given from Standard Input in the following format:
case case
For each test case, print four integers representing the answer on one line.
In the first test case, the whole rectangle forms a directed cycle.
In the second test case, the rectangle spanning rows through and columns through contains a directed cycle.
Each case is given in the following format:
Each is a string of length . The character represents the direction of the edge between and .
Each is a string of length . The character represents the direction of the edge between and .
L or R (, ).U or D (, ).In the third test case, no smaller subrectangle contains a directed cycle, so the whole rectangle is the answer.