Woburn Challenge 1999
Neo is trying to crack the code to break into the computer system of those omnipotent aliens. Whoa!! But even though he has been given the decryption algorithm by Morpheus, he still can't figure it out (remember, this is Keanu we're talking about here). So you need to help him break the code.
The system works as follows. The computer will give you a "challenge" -
an order set of at most (
,
)
). To successfully enter the system, you have to answer the challenge
by permuting the order of the elements using the given. The correct
permutation is obtained by applying one or more permutation matrices to
the challenge string as follows: a permutation MATRIX of
Input Specification
The input will consist of
Each "matrix" will contain at most
There will be at most
There will be no spaces between any of the brackets ([
, ]
, (
, )
)
and any characters following.
No line of input will contain more than
Output Specification
For each test case output the correct counterchallenge.
The output must contain one space separating each pair of set elements
(there are no spaces between the elements and the brackets!)
Sample Input
3
[3 2 1][1 3 2](a b c)
2
[2 1][2 1](a b)
-1
Sample Output
(b c a)
(a b)
Comments