ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

## 2082. Poker

Time limit: 2.0 second
Memory limit: 256 MB
Igor is a former ACM competitor. He likes to play all puzzle games and once he has implemented a checker bot. But now Igor is a grown-up and he needs to earn money. He is an engineer in a software company, but he still likes game development. Igor has an idea how to combine money and game development — he wants to implement online poker bot using machine learning techniques, optimizations on assembly language and dll-injections. For that idea he has chosen Texas Holdem.
In Texas Holdem there are two to nine players. Each of the players has some number of chips — player’s stack. During the game players make bets — put part of thier stack to the common bank. In the end of the game winner gets that bank. Players use standard 52 cards deck.
First players should bet ante. One of the players is called dealer. After that two players to the left from the dealer need to bet blinds. Small blind should be bet by the player next to the dealer, big blind — player sitting next to the small blind. These rules change a little when there are only two players in the game: small blind is bet by dealer.
Next step is card dealing. Each player gets two cards and it is only this player who knows these cards. Then the players start the round. Each round consists of stages, called streets. The streets are (in order from first to last):
• preflop
• flop
• turn
• river
If after the river there are more than one player left in the round, all these players reveal their cards and player with the best hand takes the bank. In this problem we don’t care about the cards at all.
Here is more detailed description of the round. First call on the preflop has the player next to big blind, on other streets — the player next to the dealer. During the round players make bets in turns. Players bet cannot be lower than the maximum bet on the current street — called current bet. If player does not have enough money for the current bet, he can go all in — bet all money he has. Note that the player can call all-in even if he has more maney than current bet. In the beginning of each street current bet is set to zero. But on the preflop current bet is set to big blind.
Each player can make one of the following actions:
• fold — to discard his hand. Player who folds is excluded from the round. Note that if all player except one fold then that player wins the round.
• call — to make his bet equal to the current bet, if current bet is not zero. Call means to add some money to player’s bet to make it equal to current bet.
• bet — to make bet if current bet is zero.
• raise — to add some money to his bet to make it more than current bet. Current bet should be non zero.
• check — to ship the bet. If current bet is zero player can skip the bet. Also player can skip the bet if he is big blind on the preflop and there were no raises during the preflop. If player can check and stay in the game player will do that instead of folding.
When player made an action the turn goes to the next player in clockwise diretion. The street is finished when all bets are done — all players who have not folded bet the same amount of money.
Igor’s bot is a complicated set of modules. Now Igor needs to implement the recognision module:
1. Module is called when bot needs to make a turn.
2. In that moment the computer vision component starts and gives the module the information about the current stacks of the players. Component can not recognize bets.
In the moment the module is called it has the information about start of the game and the current stacks of the players. If that is the first time when module takes turn then it should restore all players’ turns with all data it has. Otherwise module also has the information about all players’ turns before the previous bot turn. Bot needs to restore all players’ turns starting from his last turn and also that turn.
Help Igor to implement that module.

### Input

First line has 3 integer numbers — small blind sb (10 ≤ sb ≤ 500), big blind bb (20 ≤ bb ≤ 1000, sb < bb) and ante a (0 ≤ a ≤ 100).
Second line has 3 integer numbers — number of players n (2 ≤ n ≤ 9), position of the dealer d (1 ≤ dn) and position of the bot h (1 ≤ hn). Players are indexed in the order they make turns in clockwise order.
Third line contains the current street name — preflop, flop, turn or river.
Next n lines contain the description of the players in the order of their indices. Each line contains player name (non-empty string which consists of uppercase and lowercase English letters and digits with lengths no more than 20) and his initial stack (integer from 1 to 20000). All names are different and there is no name «dealing» in the input.
Next line contains a single integer k — number of actions which bot knows about (0 ≤ k ≤ 1000).
Next k lines contain these actions. Actions could be changing the street or players’ actions. Here is the format of the actions:
• deal: dealing <street>, new street that we are switching to;
• fold: <player> folds;
• check: <player> checks;
• call: <player> calls <amount>, amount > 0 — amount of money player has added to his bet;
• bet: <player> bets <amount>, amount > 0 — amount of money player has added to his bet;
• raise: <player> raises <amount> to <total>, amount > 0 — amount of money player has increased the current bet, total > amount — new current bet.
player — name of the player. If player calls all-in, that action is presented in the input as raise, bet or call.
Finally the last line contains n integers — current stacks of the players in the order of the player indices.
It is guaranteed that all actions are correct.

### Output

In the first line output the number of the actions — m. In the next m lines output the actions in the order players make them in the same format as the input.
It is guaranteed that there exists a solution and this solution is unique.

### Samples

inputoutput
```10 20 2
5 3 4
preflop
PhilIvey 500
TomDwan 500
ViktorBlom 500
Grobot 500
Ziigmund 500
0
498 478 438 488 478
```
```3
PhilIvey folds
TomDwan calls 20
ViktorBlom raises 40 to 60```
```10 20 2
5 3 4
flop
PhilIvey 500
TomDwan 500
ViktorBlom 500
Grobot 500
Ziigmund 500
3
PhilIvey folds
TomDwan calls 20
ViktorBlom raises 40 to 60
498 478 438 438 478
```
```4
Grobot calls 50
Ziigmund folds
TomDwan folds
dealing flop
```
```10 20 2
5 3 4
flop
PhilIvey 500
TomDwan 500
ViktorBlom 500
Grobot 500
Ziigmund 500
7
PhilIvey folds
TomDwan calls 20
ViktorBlom raises 40 to 60
Grobot calls 50
Ziigmund folds
TomDwan folds
dealing flop
498 478 338 438 478
```
```2
Grobot checks
ViktorBlom bets 100
```
```50 100 10
2 2 1
preflop
Grobot 2500
ViktorBlom 2000
0
2390 1890
```
```1
ViktorBlom calls 50
```
Problem Author: Igor Chevdar