9036: We are the Lights

内存限制:128 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:15 通过:8

题目描述

 
One day, Bobo was attending an international light exhibition and noticed a grid of n×m  lights arranged in nnn rows and mmm columns. Initially, all lights were off.

Bobo noticed that there were two buttons for each row and column, one for turning on and one for turning off. This means that he can perform the following four operations:

1. row  i on: turns on all the lights in row i.
2. row  i off: turns off all the lights in row i.
3. column  i on: turns on all the lights in column i.
4. column  i off: turns off all the lights in column i.

Mischievous Bobo, of course, will not miss this opportunity. You are given  operations performed by Bobo. You need to determine the number of lights that are on after performing  operations in sequence.

输入格式

 
The first line contains three positive integers , , and  (1≤n,m≤106,1≤q≤106) , denoting the number of rows and columns of the lights, and the number of operations that Bobo performs.
The next qqq lines contain an operation each, with the form of each operation already given in the problem description.

输出格式

 
Output an integer in one line, denoting the number of lights that are turned on after performing  operations in order.

输入样例 复制

2 2 3
row 1 on
column 2 off
row 2 on

输出样例 复制

3