|
<p>You are designing a new encryption system that works in the following way:<p/> |
|
|
|
<p>For server-client communication you need a key <strong>k</strong>, composed of <strong>m</strong> sections, each of length <strong>l</strong>, and the key consists only of lowercase characters in the set {a, b, c, d, e, f}. The server has a key <strong>k1</strong> and the client has a key <strong>k2</strong> where:<p/> |
|
|
|
<ul> |
|
<li>k1 = f(k). <strong>f</strong> is a function that receives a key and replace some random letters by ? indicating that those characters can be any lowercase letter of the set described before.</li> |
|
<li>k2 = f(g(k)). <strong>g</strong> is a function that takes a key and produces a random permutation of its m sections. And <strong>f</strong> is the function defined above.</li> |
|
</ul> |
|
|
|
<p>For example: let m = 3, l = 2</p> |
|
<ul> |
|
<li>f('abacbc') = '?ba??c'</li> |
|
<li>g('abacbc') = 'acbcab' (each section was moved one place to the left).</li> |
|
</ul> |
|
|
|
<p>Your task is given <strong>k1</strong> and <strong>k2</strong>, find key <strong>k</strong>. If there are several solutions, print the lexicographically smallest key. And if there is no solution at all, print "IMPOSSIBLE" (without the quotes).</p> |
|
|
|
<h2>Input description:</h2> |
|
<p>The first line has a single integer <strong>T</strong>, which corresponds to the number of test cases. <strong>T</strong> test cases follows: the first line of the test case corresponds to the integer <strong>m</strong>, the second line contains the string <strong>k1</strong> and the third line contains the string <strong>k2</strong>.</p> |
|
|
|
<h2>Constraints:</h2> |
|
<p> |
|
<ul> |
|
<li>T ≤ 20</li> |
|
<li>0 < |k1| ≤ 100</li> |
|
<li>0 < m ≤ 50</li> |
|
<li>|k2| = |k1|</li> |
|
<li>It is guaranteed that m is always a divisor of |k1|</li> |
|
<li>k1 and k2 consist of {a, b, c, d, e, f, ?}</li> |
|
</ul> |
|
<p/> |
|
|
|
<h2>Output description:</h2> |
|
<p>For test case <strong>i</strong>, numbered from <strong>1</strong> to <strong>T</strong>, output "Case #i: ", followed by the lexicographically smallest key or "IMPOSSIBLE".</p> |
|
|