# Soccer table P86236

Warning: This problem has some issue.

The system has detected that this problem may have some issue, as a mistake in its statement or a wrong solution. It should be soon be repaired by its problem setter.

Solution status: C++ . (red languages have some issue).

It is not recommended to try to solve this problem until this warning disapears.

Statement

html

You are a sports journalist that is in charge of the soccer matches in your newspaper. The editor has asked you for printing all the results of the played matches to date. However, your lack of organization is about to play a dirty trick on you: you do not find the file where yo have stored all the results! You only know the number of points that every team has won (0 for a lost, 1 for a tie, and 3 for a won match), and the played matches to date. Write a program that indicates the result of each one of the played games.

Input

For each case consists of two natural numbers, M≤ 10 and N≤ 20, representing the number of teams in the league and the number of played matches, respectively. Then, M lines come with the names of the teams and the number of points that they have. Finally, N lines come, each one of them contains the number of two of the previous team, indicating than the two team have played a match between them. The input may contain various cases, separated by a line in white. A line with the number −1 indicates the end of the input.

Output

For each test data of the input, your program must print the result of all the matches in a line, separated by spaces. If the local team has won, it must print “1”: if the visiting team has won, print “2”; if there was a tie, print “X”. We assure you that each case only admits a solution.

Scoring

• Test1:  45 Points

Tests with no more than 20 cases with M≤ 6 y N≤ 10, as the ones in the instance 1.

• Test2:  55 Points

Tests with no more than 20 cases with M≤ 10 y N≤ 20, as the ones in the instance 2.

Public test cases
• Input

```2 1
Barcelona 1

2 1
Barcelona 3

2 1
Barcelona 0

4 4
Barcelona 4
Sevilla 2
Getafe 0
Barcelona Getafe
Sevilla Barcelona

6 9
Barcelona 6
Valencia 4
Deportivo 4
Sevilla 3
Betis 3
Barcelona Deportivo
Valencia Deportivo
Valencia Barcelona
Betis Sevilla
Betis Deportivo
Betis Valencia

6 10
Barcelona 8
Valencia 4
Sevilla 4
Deportivo 2
Betis 0
Barcelona Sevilla
Betis Sevilla
Barcelona Deportivo
Betis Barcelona
Sevilla Deportivo
Deportivo Valencia

-1```

Output

```X
2
1
1 X X 2
1 1 2 2 2 2 X X X
1 1 2 2 X 2 X X 2 X
```
• Input

```10 18
Deportivo 11
Betis 9
Sevilla 6
Barcelona 5
AthBilbao 4
Espanyol 2
Valencia 1
AthBilbao Espanyol
Betis Deportivo
Valencia Deportivo
Deportivo Barcelona
Espanyol Sevilla
Valencia AthBilbao
Betis AthBilbao
Barcelona Betis

-1```

Output

```1 1 X 1 1 X X X 1 X 2 1 X 2 1 2 2 X
```
• Information
Author
Anders Jonsson
Language
English
Translator
Carlos Molina
Original language
Spanish
Other languages
Spanish
Official solutions
C++
User solutions
C++