using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC047B_Snuke_s_Coloring_2__ABC_Edit_
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');

            int w = int.Parse(input[0]);
            int h = int.Parse(input[1]);
            int n = int.Parse(input[2]);


            //Initialize
            int[,] coordinate = new int[w, h];
            for (int indexX = 0; indexX < w; indexX++)
            {
                for (int indexY = 0; indexY < h; indexY++)
                {
                    coordinate[indexX, indexY] = 1;
                }
            }

            for (int index = 0; index < n; index++)
            {
                FillRectangular(coordinate, Console.ReadLine().Split(' '), w, h);
            }

            int result = 0;
            for (int indexX = 0; indexX < w; indexX++)
            {
                for (int indexY = 0; indexY < h; indexY++)
                {
                    result += coordinate[indexX, indexY];
                }
            }


            Console.WriteLine(result);
        }

        static void FillRectangular(int[,] coordinate, string[] input2, int w, int h)
        {
            int x = int.Parse(input2[0]);
            int y = int.Parse(input2[1]);
            int a = int.Parse(input2[2]);


            int fromX = 0;
            int toX = w;
            int fromY = 0;
            int toY = h;

            switch (a)
            {
                case 1:
                    //for (int indexX = 0; indexX < x; indexX++)
                    //{
                    //    for (int indexY = 0; indexY < h; indexY++)
                    //    {
                    //        coordinate[indexX, indexY] = 0;
                    //    }
                    //}
                    toX = x;

                    break;
                case 2:
                    //for (int indexX = x; indexX < w; indexX++)
                    //{
                    //    for (int indexY = 0; indexY < h; indexY++)
                    //    {
                    //        coordinate[indexX, indexY] = 0;
                    //    }
                    //}
                    fromX = x;

                    break;
                case 3:
                    //for (int indexX = 0; indexX < w; indexX++)
                    //{
                    //    for (int indexY = 0; indexY < y; indexY++)
                    //    {
                    //        coordinate[indexX, indexY] = 0;
                    //    }
                    //}
                    toY = y;

                    break;
                case 4:
                    //for (int indexX = 0; indexX < w; indexX++)
                    //{
                    //    for (int indexY = y; indexY < h; indexY++)
                    //    {
                    //        coordinate[indexX, indexY] = 0;
                    //    }
                    //}
                    fromY = y;

                    break;
            }

            for (int indexX = fromX; indexX < toX; indexX++)
            {
                for (int indexY = fromY; indexY < toY; indexY++)
                {
                    coordinate[indexX, indexY] = 0;
                }
            }

        }
    }
}


Measured memory_bytes: 13220