3 (a)

[20 marks]

Write a program that inputs the values on one of the pairs of dice and then outputs a different pair of dice that could be used to play a fair game. Two dice are only different if they have different sides; so {1,2,3,4,5,6} and {6,5,4,3,2,1} are not different. Similarly, a different order does not distinguish two pairs of dice; so {1,2,3} and {4,5,6} is not different to {4,5,6} and {1,2,3}. The first line of input will consist of a single integer 'n' (1 <= n <= 8) denoting the number of sides all the dice will have. The second line will consist of 'n' integers (in the range 1 to 8) giving the values on the sides of the first die. The third line will also consist of 'n' integers (in the range 1 to 8) giving the values for the second die. Your output should consist of an example solution if you believe there to be one (with one die given on each line), or the word Impossible if you do not. Note that the example solution does not need to be sorted, and the value on a side can be any positive integer (i.e. values may be greater than 8).