Conveyor Belts

Worth 4 point(s) - Runtime Limit: 1 seconds


In pursuit of a more productive factory, assembly lines were created so production could be divided into simple steps. Of course, conveyor belts are used to automatically transport intermediate products throughout the factory. However, many assemblies are non-linear, resulting in complicated conveyor systems. The manager of one such assembly line has asked you to write a program to find the endpoint of a product given a map of the conveyor system and the product’s starting point. The map is an array of cells with n rows by m columns. Each cell is represented by one of the characters that follow:

The first period that the product moves onto is considered the endpoint of product.
Note that the top-leftmost cell is at (1, 1) and the bottom-rightmost cell is at (n, m). Assume that the product will never be carried off the map and that there will never be a “loop” in the conveyor system.

The first line contains an integer N, denoting the number of test cases. Each test case begins with 4 integers, n, m, r, c, respectively, denoting an n by m map and a starting point of row r and column c. The next n lines contain m characters each, denoting the conveyor map with the notation above.

For each test case, output a line containing the row and column of the product’s endpoint with a space in between.

Sample Input

5 5 1 1

Sample Output

5 3