Soccer table

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, M10M\leq 10 and N20N\leq 20, representing the number of teams in the league and the number of played matches, respectively. Then, MM lines come with the names of the teams and the number of points that they have. Finally, NN 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-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

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T12:08:01.735Z

© Jutge.org, 2006–2026.
https://jutge.org