Mirko paid a touristic visit to a land far away where banknotes aren't used, but only coins. More precisely,
the country has types of coins in circulation. Their names are, respectively,
K1
, K2
, …, 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 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 to
and after that performed
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.
Input Specification
The first line of input contains integers ,
, and
– the number of types of coins in the country, the
number of coins in Mirko's pocket and the number of weighings.
Each of the following lines contains the result of one weighing in the form of
where
and
are
different integers less than or equal to
, and
is the character
=
(equal) or <
(less).
There is no space between the numbers and character . The result of one weighing tells us that Mirko's
coin marked with
is of equal weight as the coin marked with
or lighter than it.
The weighing results won't be contradictory.
Output Specification
Output lines. The
line must contain the type of coin marked with
– a sequence of characters of the
form
KX
where is an integer between
and
.
If it isn't possible to uniquely determine the weight of the coin marked with , output the character
?
in
the line.
Constraints
For all subtasks:
Subtask | Score | Constraints |
---|---|---|
Sample Input 1
3 5 3
1<2
2<4
3=5
Sample Output 1
K1
K2
?
K3
?
Sample Input 2
2 7 6
1=2
2=3
2=7
3<4
4=5
4=6
Sample Output 2
K1
K1
K1
K2
K2
K2
K1
Comments