- Time limit: 3.00 s
- Memory limit: 256 MB
In our programming course, our students have written programs that are supposed to solve the following problem: given an integer and an table they should construct an table such that Put otherwise, element in table should be the dot product of rows and in table , modulo 64.
Now your task is to quickly verify that the students have really solved the problem correctly. You will get , table , and table , and you need to check if the solution is correct.
Input
The first line of input contains one integer, , which is the number of test cases. Each case consists of:
- one line with integer
- table : lines with characters
- table : lines with characters
The tables are encoded as strings as follows:
- each character corresponds to one element,
- characters
A
toZ
correspond to values 0 to 25, - characters
a
toz
correspond to values 26 to 51, - characters
0
to9
correspond to values 52 to 61, - character
+
corresponds to value 62, - character
/
corresponds to value 63.
As everything is calculated modulo 64, we only need to store values 0–63.
Output
For each case, you will need to output one line: either 1
if is correct, or 0
if is not correct.
Limits
- the sum of all values is at most 5000
Example
Input:
3 2 BC DE FL LZ 2 BC DE FL LF 4 m2ct 4k2u MY0u hrQW BmeW m48Y e8kI WYIe
Output:
1 0 1
Here we have three test cases (). In the first case we have and Here all values are correct. For example, . In the second test case the last element of is incorrect.