Astronauts

The Bandulu Space Agency (BSA) has plans for the following three space missions: • Mission A: Landing on Ganymede, the largest moon of Jupiter. • Mission B: Landing on Callisto, the second largest moon of Jupiter. • Mission C: Landing on Titan, the largest moon of Saturn. Your task is to assign a crew for each mission. BSA has trained a number of excellent astronauts; everyone of them can be assigned to any mission. However, if two astronauts hate each other, then it is not wise to put them on the same mission. Furthermore, Mission A is clearly more prestigious than Mission B; who would like to go to the second largest moon if there is also a mission to the largest one? Therefore, the assignments have to be done in such a way that only young, inexperienced astronauts go to Mission B, and only senior astronauts are assigned to Mission A. An astronaut is considered young if their age is less than the average age of the astronauts and an astronaut is senior if their age is at least the averageage. Every astronaut can be assigned to Mission C, regardless of their age (but you must not assign two astronauts to the same mission if they hate each other). Input The input contains several blocks of test cases. Each case begins with a line containing two integers 1 ≤ n ≤ 100000 and 1 ≤ m ≤ 100000. The number n is the number of astronauts. The next n lines specify the age of the n astronauts; each line contains a single integer number between 0 and 200. The next m lines contains two integers each, separated by a space. A line containing i and j (1 ≤ i, j ≤ n) means that the i-th astronaut and the j-th astronaut hate each other. The input is terminated by a block with n = m = 0. Output For each test case, you have to output n lines, each containing a single letter. This letter is either ‘A’, ‘B’, or ‘C’. The i-th line describes which mission the i-th astronaut is assigned to. Astronauts that hate each other should not be assigned to the same mission, only young astronauts should be assigned to Mission B and only senior astronauts should be assigned to Mission A. If there is no such assignment, then output the single line ‘No solution.’ (without quotes). Sample Input 16 20 21 22 23 24 25 26 27 28 101

2/2 102 103 104 105 106 107 108 12 34 56 78 9 10 11 12 13 14 15 16 1 10 29 3 12 4 11 5 14 6 13 7 16 8 15 1 12 1 13 3 16 6 15 00 Sample Output B C C B C B C B A C C A C A C A