# Learning BFS 1

Given N vertices and an Adjacency Matrix of an

**Unâ€Źdirected Graph**.

Find the minimum distance from Source(S) to Destination(D).

If it is not Reachable display -1.

**Input**

First Line contains single integer t containing number of test cases that follow.

First Line of each test case consists of a single integer N denoting the number of vertices.

Second Line contains two integers Source(S) and Destination(D).

Next N lines each containing N elements describe the Adjacency Matrix.

**Output**

T lines , one line for each test case containing a single Integer that gives minimum distance required to reach D from S.

If it is unreachable output -1.

**Constraints**

0 < N < 25

0 <= S,D < N

**Sample Input**

```
```

2

3

0 2

0 1 0

1 0 1

0 1 0

2

0 1

0 0

0 0

**Sample Output**

```
```

2

-1

**PS: Apply BFS :P***Problem Setter : Shikhar Sharad*

*Problem Tester : Arjun Singh Bhatia*

**Languages:**Brain,C,C++,Java,Pascal,Perl,PHP,Python,Ruby,Text