6- Mirror

5

1 votes
Problem

There is a NxN Grid in which there are empty cells ( denoted by "." ) while some cells have rocks in them (denoted by "@" )and some cells have mirror (denoted by "/" ) at 45 degrees so that a person standing on south of the grid can see what is happening in East side by reflection from the mirror, if there is no rock or another mirror in the line.

You have to tell whether or not a person standing on south side will be able to see what's happening on the east side. if yes print "1" else if No print "0"

INPUT FORMAT-

First line of input contains no of test cases.

Each test case consists of N+1 lines

First line of each test case consist of a number N denoting the size of NxN grid

Next N lines of each test case contain N characters.("." , "/" , "@")

Note: A mirror "/" can reflect rays coming from only south side of the grid.

OUTPUT FORMAT-

one line of each test case containing "0" or "1"

Sample Input-

2

4

/@/.

/../

.@.@

....

2

/.

@.

Sample Output-

1

0

Mirror

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?