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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;
        
        static void Solve()
        {
            var o = ReadAndParseIntArr();
            int w = o[0];
            int h = o[1];
            int n = o[2];
            var x = new int[n];
            var y = new int[n];
            var a = new int[n];
            for(int i=0;i<n;++i)
            {
                o = ReadAndParseIntArr();
                x[i] = o[0];
                y[i] = o[1];
                a[i] = o[2];
            }
            bool[,] box = new bool[h, w];
            for(int i=0;i<n;++i)
            {
                int op = a[i];
                if( op == 1)
                {
                    Fill1(box, x[i], h, w);
                }else if( op == 2)
                {
                    Fill2(box, x[i], h, w);

                }
                else if (op == 3)
                {
                    Fill3(box, y[i], h, w);

                }
                else if( op == 4)
                {
                    Fill4(box, y[i], h, w);

                }
            }

            int ans = 0;
            for(int i= 0;i<h;++i)
            {
                for(int j=0;j<w;++j)
                {
                    if( !box[i,j])
                    {
                        ans++;
                    }
                }
            }
            Console.WriteLine(ans);
        }
        private static void Fill1(bool[,] box, int x, int h, int w)
        {
            for(int i=0;i<h;++i)
            {
                for(int j =0;j<x;++j)
                {
                    box[i, j] = true;
                }
            }
        }
        private static void Fill2(bool[,] box, int x, int h, int w)
        {
            for (int i = 0; i < h; ++i)
            {
                for (int j = w-1; j >= x; --j)
                {
                    box[i, j] = true;
                }
            }
        }
        private static void Fill3(bool[,] box, int y, int h, int w)
        {
            for (int i = 0; i < y; ++i)
            {
                for (int j = 0;j<w;++j)
                {
                    box[i, j] = true;
                }
            }
        }
        private static void Fill4(bool[,] box, int y, int h, int w)
        {
            for (int i = h-1; i >= y; --i)
            {
                for (int j = 0; j < w; ++j)
                {
                    box[i, j] = true;
                }
            }
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 13120