| 2020-2021 ICPC, Moscow Subregional |
|---|
| Finished |
In a modern professional sport it is common for team managers to make game-related decisions based on statistics instead of personal impression. That is even more common for games that feature repetitive actions and the same player's dispositions many times per game, and each team is expected to score tens of times. Basketball is such a game and this task is about popular plus-minus statistics for individual players.
Each team has ten players for a game. At every moment of time each team has exactly five players on the court and five players in reserve. For the purpose of this problem we consider that substitutions are unlimited and can take place at any moment of time. Moreover, there are no restrictions on the number of substitutions for each particular player.
At the beginning of the game the individual score of each player is $$$0$$$. Every time some team scores $$$x$$$ points ($$$x = 1$$$, $$$x = 2$$$ and $$$x = 3$$$ are the options), the individual score of each player of this team who is currently on the court is increased by $$$x$$$. For the opposing team, the individual score of each player who is on the court is reduced by $$$x$$$. Individual score can become negative. No score changes take place for the players of both teams who are currently in reserve.
You are given the protocol of the game that has information about the players on the court at the beginning of the game, substitutions and scoring events.
Your task is to compute the individual scores of the plus-minus statistics for all players that appeared on the court at least once.
The first line of the input contains the name of the first team. Then follow five lines containing names of the players, who are playing for the first team at the beginning of the game.
Then follow six lines containing the name of the second team and five names of the players of the second team that are on court at the beginning of the game.
Then goes the description of the game protocol. The first line of this description contains a single integer $$$q$$$ ($$$1 \leq q \leq 1000$$$) — the number of events to consider.
Then follow $$$q$$$ events listed in chronological order.
Each event is of one of two types.
All names are non-empty strings of no more than $$$80$$$ characters. Lowercase and uppercase English letters are allowed. Team's names are distinct, there are no two players with the same name in one team.
For each player that appeared in the play (on the court) at least once print his name, team and individual plus-minus score on a separate line.
List the players in the order they are mentioned in the input for the first time. First, print the name of this player, then print the name of this player's team in brackets "()" (see sample output), finally print the score. Positive scores should be printed with '+' sign and negative with '-'. Zero scores should have no sign at all.
Lakers James Davis Howard Green ColdwellPope Clippers Leonard George Zubac Beverley Morris 10 Team Lakers scored 2 Team Clippers replaced George with Williams Team Clippers scored 3 Team Clippers scored 1 Team Lakers replaced Howard with Caruso Team Lakers replaced Green with Morris Team Lakers scored 2 Team Clippers replaced Zubac with George Team Lakers scored 2 Team Lakers scored 3
James (Lakers) +5 Davis (Lakers) +5 Howard (Lakers) -2 Green (Lakers) -2 ColdwellPope (Lakers) +5 Leonard (Clippers) -5 George (Clippers) -7 Zubac (Clippers) 0 Beverley (Clippers) -5 Morris (Clippers) -5 Williams (Clippers) -3 Caruso (Lakers) +7 Morris (Lakers) +7
| Name |
|---|


