프로그램 명: coci_kovanice
제한시간: 2 초

Mirko paid a touristic visit to a land far away where banknotes aren’t used, but only coins. More precisely, the country has N types of coins in circulation. Their names are, respectively, ‘K1’, ‘K2’, ‘K3’, . . . , ‘KN’.

The coins are of the same size and shape, but different weights. ‘K1’ is the lightest type of coin, ‘K2’ is the second lightest and so on until the heaviest type ‘KN’.

Mirko has M coins in his pocket, but he doesn’t know which one is of which type. In order to determine that, he only has a simple balance scale at his disposal. Initially, Mirko marked his unknown coins with numbers from 1 to M and after that performed V weighings.

In each weighing, he put one coin on one side of the scale, and another coin on the other side of the scale. Then he saw whether the two coins weigh equally, and if they don’t, which one is heavier.

Write a programme that will, based on the weighing results, determine the type of coin for each coin for which it is possible to determine it uniquely.

입력

출력

Output M lines. The i-th line must contain the type of coin marked with i - a sequence of characters of the form ‘KX’ where X is an integer between 1 and N.

If it isn’t possible to uniquely determine the weight of the coin marked with i, output the character ‘?’ in the i-th line.

입출력 예

입력

3 5 3
1<2
2<4
3=5

출력

K1
K2
?
K3
?

입력

2 7 6
1=2
2=3
2=7
3<4
4=5
4=6

출력

K1
K1
K1
K2
K2
K2
K1
출처:2013-2014 olympiad 2/4

[질/답] [제출 현황] [푼 후(0)]
[ 채 점 ] [홈으로]  [뒤 로]