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, 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:

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

- Test2:

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

Problem information

Author: Unknown
Translator: Carlos Molina

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

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