Teacher Mai has a multiplication table in base p.
For example, the following is a multiplication table in base 4:
0 00 00 00 00
1 00 01 02 03
2 00 02 10 12
3 00 03 12 21
But a naughty kid maps numbers 0..p-1 into another permutation and shuffle the multiplication table.
For example Teacher Mai only can see:
11=11 13=11 12=11 10=11
31=11 33=13 32=12 30=10
21=11 23=12 22=31 20=32
01=11 03=10 02=32 00=23
Teacher Mai wants you to recover the multiplication table. Output the permutation number 0..p-1 mapped into.
It's guaranteed the solution is unique.