Warning: This problem has some issue.

The system has detected that this problem may have some issue, as a mistake in its statement or a wrong solution. It should be soon be repaired by its problem setter.

Solution status: C++ . (red languages have some issue).

It is not recommended to try to solve this problem until this warning disapears.

Ann and Bob like to play a variant of Battleship.
First, they agree on the number of rows *r*
and the number of columns *c* of a rectangular grid,
and also on a length *m*.
Afterwards, Ann decides a place to hide exactly one ship
of size 1 × *m* completely inside the grid,
either horizontally or vertically.
Then, Bob tries to sink Ann’s ship
by shoting at *n* cells of the grid.
For every shot, Ann must say if the ship has been hit,
or if the shot has been a miss.

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.

**Input**

Every case begins with *r*, *c*, *m* and *n*.
Follow *n* triples *i*, *j*, *x*,
where 1 ≤ *i* ≤ *r* is the row of the shot,
1 ≤ *j* ≤ *c* is the column of the shot,
and *x* is a character that is ‘`h`’ or ‘`m`’
depending on whether the shot is a hit or a miss according to Ann.
Assume
1 ≤ *r* ≤ 10^{8},
1 ≤ *c* ≤ 10^{8},
2 ≤ *m* ≤ 100,
and 0 ≤ *n* ≤ 10^{5}.
The coordinates of all the shots are different.

**Output**

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.`”.

Public test cases

**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

Information

- Author
- Salvador Roura
- Language
- English
- Official solutions
- C++
- User solutions
- C++