Coin type identification

No attempts yetTime limit2sMemory limit512 MB

Problem

Mirko visited a distant country where nobody uses banknotes, only coins. The country has NN types of coins in circulation, named K1, K2, K3, ..., KN. All coins have the same size and shape, but their weights differ. K1 is the lightest type, K2 is the second lightest, and so on up to KN, the heaviest type.

Mirko has MM coins in his pocket and does not know which type each one is. The only tool he has for finding out is a simple balance scale.

Mirko first labelled his unknown coins with the numbers 11 through MM, and then performed VV weighings. In one weighing he puts one coin on one side of the scale and another coin on the other side. He then sees whether the two coins weigh the same, and if they do not, which one is heavier.

Write a program that uses the weighing results to determine the type of every coin whose type is fixed by those results.

Input

The first line contains the integers NN, MM and VV: the number of coin types in the country, the number of coins in Mirko's pocket, and the number of weighings.

Each of the next VV lines holds the result of one weighing in the form ACB, where AA and BB are different positive integers not greater than MM, and CC is the character = (equal) or < (lighter).

There is no space between the numbers and the character CC. One weighing result says that Mirko's coin numbered AA weighs the same as the coin numbered BB, or is lighter than it.

The weighing results are never contradictory.

Output

Print MM lines. Line ii must contain the type of the coin numbered ii, written as KX, where XX is an integer between 11 and NN.

If the type of the coin numbered ii cannot be determined uniquely, print the character ? on line ii.

Constraints

In all subtasks, 2N3000002 \le N \le 300\,000, 2M3000002 \le M \le 300\,000 and 1V3000001 \le V \le 300\,000.