#include<iostream>
#include<bitset>
#include<algorithm>
#include<vector>
#include<cstdio>
#define MAX 50001
using namespace std;
struct Query
{
  int A,B,order;
  Query(int A=-1,int B=-1,int order=-1):A(A),B(B),order(order){}
};
int r,c,q;
bool used[2][MAX];

int main()
{
  while(true)
    {
      scanf("%d %d %d",&r,&c,&q);
      if(r+c+q == 0)break;
      for(int i=0;i<MAX;i++)used[0][i] = false;
      for(int j=0;j<MAX;j++)used[1][j] = false;
      Query queries[q];
      for(int i=0;i<q;i++)
	scanf("%d %d %d",&queries[q-(i+1)].A,&queries[q-(i+1)].B,&queries[q-(i+1)].order);
	
      int ru,rd,cu,cd,total;
      ru = rd = cu = cd = total = 0;

      for(int i=0;i<q;i++)
	{
	  Query qw = queries[i];
	  //cout << "query -> " << qw.A << " " << qw.B << " " << qw.order << endl;
	  if(used[qw.A][qw.B])continue;
	  used[qw.A][qw.B] = true;

	  if(qw.order)
	    {
	      if(!qw.A)
		{
		  total += c - (ru+rd);
		  cu++;
		}
	      else 
		{
		  total += r - (cu+cd);
		  ru++;
		}
	    }
	  else
	    {
	      if(!qw.A)
		{
		  cd++;
		}
	      else 
		{
		  rd++;
		}
	    }
	  //cout << i << " - th : " << total << endl;  
	}
      cout << total << endl;
    }
  return 0;
}