Golden Field#10489

Golden Field

2 seconds
64 megabytes
Easy

Given an n \times m grid. Each cell is initially black.

Kozak Vus can perform an operation to choose any row or column and invert all cells in it, i.e., each black cell becomes gold, and each gold cell becomes black.

Given the operations that Kozak Vus will perform, find the number of gold cells after all operations have been executed.

Input

The first line contains a single integer (1 \leq n \leq 5 \cdot 10^6) — the number of rows.

The second line contains a single integer (1 \leq n \cdot m \leq 5 \cdot 10^6) — the number of columns.

Note that the constraint n \cdot m \leq 5 \cdot 10^6 is satisfied.

The third line contains a single integer (1 \leq q \leq 10^6) — the number of operations.

Each of the next lines contains the character «R» (row) or «C» (column), followed by a single integer (1 \leq r \leq n) or (1 \leq c \leq m) depending on the character.

Output

Output the number of gold cells after all operations have been completed.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading

Scoring

  1. ( points): n=1, m=1, q \leq 100;

  2. ( points): n=1, m \leq 100, q \leq 100;

  3. ( points): n \leq 100, m \leq 100, q \leq 100;

  4. ( points): no additional constraints.