After watching the movie 21, JN is curious about casino.
There are one banker and one guard in the casino. They have banker_ski and guard_ski skill respectively.
There are N players playing twenty one. The i-th of them has mi dollars and skii skill.
There will be K rounds of twenty one in total today.
In each round, each of the players place their bets beti first, then draw some cards.
The banker draws the cards last.
Let A be the sum of the i-th player's cards, B be the sum of the banker's.
Then:
For the banker:
For the guard:
For the player:
The banker and the guard have 0 dollars at first.
You can use the following code to draw cards.
this->cards = 0;
string res = "";
while (res.size() <= 0)
getline(cin, res);
stringstream ss(res);
while (ss >> res) {
int temp = 0;
for (int i = 0; i < (int)res.size(); ++ i)
temp = temp * 10 + res[i] - '0';
this->cards += temp;
}
The first line of the input contains two numbers — guard_ski and banker_ski.
The second line of the input contains a number N — the number of players.
Each of the next N lines contains a string namei and two numbers mi and skii — the name, money, and the skill the i-th player has.
The next line contains a number K — there will be K rounds of twenty two today.
The following contains K blocks, i = 1, ..., N.
There will be a string namei and a number beti in the 2i - 1 line — the i-th player's name and the bets they place.
There will be some numbers c1, ..., ct in the 2i line — the cards the i-th player has.
The last line of each block will be some numbers c1, ..., ct — the cards the banker has.
N, K <= 500.
All the other numbers <= 5*104.
You should print N+1 lines in total.
The first line of output should contains two numbers guard_money and banker_money — the money the guard and the banker gets.
Each of next N lines should contains a string namei and moneyi — the name of the i-th player and the money they have after playing.