There are teams (labeled from to ) that participate each year in a programming competition, and at the end they are ranked in order of merit. Last year's rankings are known.
This year, the jury decides to make the event less competitive and chooses not to publish the complete ranking list (since teams near the bottom might get disheartened). Instead, they publish a complete list of pairs of teams whose relative ranking order has changed compared to last year. For example, if team was ranked above team last year, but this year team is ranked above team , the pair is reported. This allows teams to track their progress against particular rivals, but not fully determine the overall ranks.
Of course, this does not stop your team from trying to reconstruct the entire ranking. Given last year's rankings and a complete list of team pairs whose relative ranking has changed, reconstruct as much of this year's ranking as possible. If the given data is inconsistent with any valid ranking for this year, you should also detect this.
The first line contains a positive integer: the number of test cases, at most . Then for each test case:
One line with the integer (2 \le n \le 500): the number of teams.
One line with integers t_i (1 \le t_i \le n): last year's ranking from best to worst. t_i is the team in position (1-indexed) of the ranking. All t_i are distinct.
One line with integer (0 \le m \le 25\ 000): the number of pairs whose relative order changed.
lines, each with two integers a_i and b_i (1 \le a_i < b_i \le n): a pair of teams whose relative order changed. Each such pair appears exactly once.
For each test case:
One line with integers: this year's rankings from best to worst, where the -th value (1-indexed) is the team ranked -th. If the team cannot be determined unambiguously, replace the integer with a '?' character. If the data is inconsistent with any possible ranking, output a line containing "IMPOSSIBLE" instead.
Ejemplo 1