A new race was identified to live on ZOLO, a newly discovered planet. The DNA of these people is much simpler than that of human beings. Each trace is coded by a square of size n x n where n is an even number and 2 n 50. Each cell of the square is either 0 (OFF) or 1 (ON). Scientists discovered that the relationship between two persons is based on the similarity between the cells of the person with the smaller square trace and the cells of an equal size square centered in the middle of the trace of the person with larger square trace. (the two traces can be of equal size). The relationship is based on the following findings:

• If the number of ones of the corresponding rows in the compared traces are equal (e.g. row#0 of first trace with row#0 of the second trace, row#1 of the first trace with row#1 of the second trace, and so on), then they are related from their mothers’ sides.

• If the number of ones of the corresponding columns in the compared traces are equal (e.g. column#0 of first trace with column#0 of the second trace, column#1 of the first trace with column#1 of the second trace, and so on), then they are related from their fathers’ sides.

• If the number of ones of the corresponding rows and the corresponding columns in the compared traces are equal, then they are related from both their mothers sides and fathers sides.

For example, suppose, two persons X and Y have the following traces, respectively:

0 1 1 1 1 0

0 0 0 0 0 0

1 1 1 1 1 0

1 1 1 0 0 0

1 1 1 0 1 1

1 1 1 1 1 1

1 1 0 1

1 1 1 1

1 0 0 0

0 1 0 0

We say X and Y are related from their fathers’ sides since the number of ones of the corresponding columns are equal.

Input

The input data is stored in file “digital.in”. The first line of the input file contains a single integer t (1 t 10), the number of test cases, subsequent lines correspond to the t test cases.

For each test case, the first line contains the number of rows in the small trace person. The subsequent line(s) contains data to fill the cells of that person row by row. Then, a line that contains the number of rows of the larger or equal size trace person. The subsequent line(s) contains data to fill the cells of the person with larger or equal size trace row by row.

Output

The output should be stored in file “digital.out”. The output should contain one line for each test case (as shown in the sample output below) indicating the type of relationship between the two persons as follows: Mothers’ sides, Father’s sides, Both sides, or Not related

Sample Input

The following input file contains 2 test cases. The first test case corresponds to 4x4 and 6x6 traces of two persons, and the second test case corresponds to 2x2 and 4x4 traces of another couple of persons.

2

4

0 0 0 0

1 1 1 1

1 1 0 0

1 1 1 1

6

0 1 1 1 1 0

0 0 0 0 0 0

1 1 1 1 1 0

1 1 1 0 0 0

1 1 1 1 1 1

1 1 1 1 1 1

2

1 1

0 1

4

1 1 1 1

1 1 1 1

1 0 0 0

0 0 0 1

Sample Output

Case 1: Both sides

Case 2: Not related

THIS IS MY ASSIGNMENT QUESTION !