find-the-pattern

Raju remembers his childhood days and it reminds him of his favourite game 'Find the pattern'. He memorizes that there is a problem pattern and there are four options available. He had to choose the correct pattern from the options that fits correctly with the problem pattern and when both are merged together they form a square. Also, that game contains difficult problems in which first he has to rotate the problem pattern and then find the correct option.

Given a problem pattern and four options, find the correct option that fits exactly with the problem pattern and forms a square of 10 × 10. The problem pattern can be rotated through 90 degrees, 180 degrees or 270 degrees as required.

Note:
All the patterns contains characters 'X' and '_'.

Input

The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
Each test case contains five patterns of size 10 × 10 characters.There is a blank line after each pattern.
The first pattern is the problem pattern and the next four patterns are options to the solution. One of these four patterns is the solution to the first pattern.

Output

For each test case print the relative position of the correct option from the problem pattern.

Constraints

1 ≤ T ≤ 100

SAMPLE INPUT
1
__________
X_X_______
X_X_______
X_X_______
X_X______X
X_X_____XX
X_XX_X_XXX
X_XX_X_XXX
XXXXXXXXXX
XXXXXXXXXX

XXXXXXXXXX
XXXXXXXXXX
XXXXX_XXXX
XXXXX_XXXX
_XX____XXX
_XX____XXX
_XX____X__
_X_____X__
_______X__
__________

X_________
XXXXXXX___
XXXXXXXX__
XXXXXXXXX_
XXXXXXX___
XXX_______
XXX_______
XXXXX_____
XXXX______
XXXX______

_________X
__XXXXXXXX
_________X
____XXXXXX
__XXXXXXXX
____XXXXXX
__XXXXXXXX
____XXXXXX
_____XXXXX
______XXXX

________XX
____XXXXXX
_______XXX
______XXXX
__XXXXXXXX
_________X
______XXXX
______XXXX
____XXXXXX
___XXXXXXX

SAMPLE OUTPUT
3

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions: