All Submissions


Yesterday, my friend from Robolution asked me to to solve a problem. They were organizing a contest. In that they have an arena made up of small squares placed as a grid. Your bot cannot go to some squares X. The aim of the bot is to reach the sqaure F nearest to the destination at square D. Now he is stuck with the program. Your task is to write a program so that the bot reaches to a square nearest reachable to the destination or the destination if possible.

Input

All squares where you can move are denoted as A
All squares where you can not move are denoted as X.
First line is the number of test cases T.
For each test case you are give the number of rows (R) and columns (C) separeated by space.
Next two lines consist of the cordinates of sourse S and Destination D separated by space.
Next R lines contain the list of square in each C coloumn.

Output

you need to list the cordinates of square F in first line and number of moves in the second.
In case of two squares being at same least distance to the destination, take the one which requires shortest path.
The input will have a particular answer only.

Constraints

1<=T<=20
2<=R<=30
2<=C<=30

Sample Input


1
6 7
0 0
4 4
AAAAAAA
AAAAAAA
AAXXAXA
AAXXXXA
AAXXAXA
AAXXXXA


SAMPLE OUTPUT


2 4
6


Problem by: Piyush Garg

Languages: C,C++,Java

Time Limit: 1 Second(s)
Score: 100 Point(s)
Input File Limit: 50000 Bytes

Submit

Login to post clarification.

No Clarifications.

Contest

Mode Judge

Passive

Online

Overall Rankings

RankNameScore
1xyz0
2Ams0
3TIP0
4team420
5xyzz0
6asdasdasd0
7abcd0
8khankhan0
9Gabriel0
10gigel0