Working with Relations 

The wages of the employees of a company are computed on the basis of a set of relative rankings of the form x R y, where x and y are names and/or numbers, and R is a relational operator from the set {<, <=, >, >=, =}. The meaning of x R y is:

the salary of x   the salary of y
  must be in relation R with  
number x   number y

The problem is to compute the minimum and the maximum wage which each of the employees can get according to a given set of relations. It is known that: the name of an employee is at most 8 characters long; the wages are integers from 1 to 99999; only integer numbers appear in relations; the number of employees cannot exceed 100 and the number of relations is at most 1000.

Input 

The program input is from a file which contains several sets of relations as shown in the sample input below. The relations of a set are one on a line and their elements are separated by spaces. Each set of relations ends with a line which contains a minus sign only. The format of input data is correct.

Output 

The result of the program is on standard output. For each consistent set of relations the result is the message `OK' followed by the list of employees (if any), in alphabetical order, together with their minimum and maximum wages as shown in the sample output. If a set of relations is inconsistent then the message `No solution' is printed for that set. Notice that for a set of relations which contains only numbers the result can be either the message `OK' or `No solution'. Print a blank line between two consecutive test cases.

Sample Input 

Fido < 20
Bibo <= Fido
Fred < Bibo
20 > Fred
-
1 <= 3
1 = 1
-
Fido < 20
Bibo < Fido
20 < Fido
-

Sample Output 

OK
Bibo         2    19
Fido         2    19
Fred         1    18

OK

No solution



Miguel Revilla
2001-01-05