0.67 Ann and Bob like to play a variant of Battleship. First, they agree on the number of rows and the number of columns of a rectangular grid, and also on a length . Afterwards, Ann decides a place to hide exactly one ship of size completely inside the grid, either horizontally or vertically. Then, Bob tries to sink Ann’s ship by shoting at cells of the grid. For every shot, Ann must say if the ship has been hit, or if the shot has been a miss.
0.33
You are looking at one game between Ann and Bob, and you suspect that Ann is cheating. To confirm or refute your suspicions, please count the number of positions where the ship could be placed according to Ann’s answers.
Every case begins with
,
,
and
.
Follow
triples
,
where
is the row of the shot,
is the column of the shot, and
is a character that is ‘h’ or ‘m’ depending on
whether the shot is a hit or a miss according to Ann. Assume
,
,
,
and
.
The coordinates of all the shots are different.
For every case, print the number of possible locations of the ship
hidden by Ann. If this number is 0 or if Ann’s answers are clearly
wrong, print “Ann is cheating.”.
Input
1 2 2 0 4 6 3 0 4 6 3 1 2 3 m 4 6 3 1 2 3 h 4 6 3 2 2 3 h 2 4 m 4 6 5 0 3 3 4 0 1 7 4 1 1 4 m 1 7 4 2 1 4 h 1 1 h 1 7 4 2 1 5 h 1 1 h 100000000 100000000 2 0
Output
1 28 23 5 3 8 Ann is cheating. Ann is cheating. 1 Ann is cheating. 19999999800000000