URI Online Judge | 2051

Karnaugh Maps I

By Lucas Lise, URI Online Judge BR Brazil

Timelimit: 1

Karnaugh map is a table set up to facilitate the minimization process of logical expressions. They allow simplifications 2, 3, 4 or more variables, this problem we use expressions at most 4 variables. Your task is simple, given the truth table you should print their map Karnaugh and say if the expression is a "Tautologia" a "Contradicao" or "Contingencia".

Input

The first line of input file contains an integer N (0 ≤ N ≤ 50) indicating the number of test cases in the first test case of the line contains an integer V [2, 3, 4] indicating the number of variables that will be used the next 2V lines contain the truth table.

Output

For each case, you should display the message "Mapa de Karnaugh", followed by the same as the example below, after presenting the map you must identify whether it is "Tautologia", "Contradicao" or "Contingencia", a blank line must separate test cases, care spaces, the values in the map should be aligned with the first digit of the column.

Input Sample Output Sample

3
2
0 0 - 1
0 1 - 1
1 0 - 0
1 1 - 1
3
0 0 0 - 0
0 0 1 - 0
0 1 0 - 0
0 1 1 - 0
1 0 0 - 0
1 0 1 - 0
1 1 0 - 0
1 1 1 - 0
4
0 0 0 0 - 1
0 0 0 1 - 1
0 0 1 0 - 0
0 0 1 1 - 1
0 1 0 0 - 0
0 1 0 1 - 1
0 1 1 0 - 1
0 1 1 1 - 0
1 0 0 0 - 1
1 0 0 1 - 1
1 0 1 0 - 0
1 0 1 1 - 1
1 1 0 0 - 0
1 1 0 1 - 1
1 1 1 0 - 1
1 1 1 1 - 0 

Mapa de Karnaugh
  0 1
0|1 0
1|1 1
Contingencia


Mapa de Karnaugh
  00 01 11 10
0|0  0  0  0
1|0  0  0  0
Contradicao


Mapa de Karnaugh
   00 01 11 10
00|1  0  0  1
01|1  1  1  1
11|1  0  0  1
10|0  1  1  0
Contingencia