PivotOJ

Over the Hill, Part 2

시간 제한: 1000ms메모리 제한: 1024MB출처: ICPC ECNA 2020-2021BOJ 21155

문제

Bob Roberts is part of a crack espionage team working for the CIA (Chocolate Institute of Alabama) and he is working on decrypting the encoded messages of their arch rivals at the NSA (Nougat Society of Arkansas).  Fortunately, the NSA's espionage staff is not nearly as crack as Bob's as they are using the Hill encryption scheme (described in the previous problem) which is susceptible to a known-plaintext attack.  Bob has intercepted a plaintext/ciphertext pair and has knowledge of the size of the encryption matrix used by his not-so-sweet enemies. Given these Bob knows that there is a way to determine the encryption matrix, but no one on his staff is exactly sure how (hmmm \ldots not quite as crack as they thought).  Bob's come to you to solve this problem for them.  One complication is that there might not be enough data to uniquely determine the NSA's encryption matrix, and the data they intercepted might have been corrupted leading to no solution to the problem.

입력

Input begins with a line containing a positive integer n10n \leq 10 indicating the size of the matrix and the vectors to use in the encryption.  After this are two lines: the first of these contains the plaintext and the second the ciphertext. Both of these lines will consist only of characters in the set A, \ldots, Z,0, \ldots, 9 and the space character.  The lengths of both strings are identical and are multiples of nn.  Both of these strings may include trailing blanks.

출력

Output one of three possible answers.  If the input does not admit any possible encryption matrix output No solution.  Otherwise if the input does not uniquely determine the encryption matrix output Too many solutions.  Otherwise output the encryption matrix, one row per line with a single space between values on a line.

예제

예제 1

입력
3
ATTACK AT DAWN 
FPLSFA4SUK2W9K3
출력
30 1 9
4 23 7
5 9 13

예제 2

입력
3
ATTACK
FPLSFA
출력
Too many solutions

예제 3

입력
3
ATTACK AT DAWN 
EPLSFA4SUK2W9K3
출력
No solution
코드를 제출하려면 로그인하세요.