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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            B();
        }

        static void B()
        {
            var WHN = ReadSplitInt();
            var W = WHN[0];
            var H = WHN[1];
            var N = WHN[2];
            var menseki = new int[H, W];

            for (var i = 0; i < N; i++)
            {
                var xya = ReadSplitInt();
                var x = xya[0];
                var y = xya[1];
                var a = xya[2];

                if (a == 1)
                {
                    for (var h = 0; h < H; h++)
                    {
                        for (var w = 0; w < x; w++)
                            menseki[h, w] = 1;
                    }
                }
                else if (a == 2)
                {
                    for (var h = 0; h < H; h++)
                    {
                        for (var w = x; w < W; w++)
                            menseki[h, w] = 1;
                    }
                }
                else if (a == 3)
                {
                    for (var h = 0; h < y; h++)
                    {
                        for (var w = 0; w < W; w++)
                            menseki[h, w] = 1;
                    }
                }
                else
                {
                    for (var h = y; h < H; h++)
                    {
                        for (var w = 0; w < W; w++)
                            menseki[h, w] = 1;
                    }
                }
            }

            var ans = 0;
            for (var h = 0; h < H; h++)
            {
                for (var w = 0; w < W; w++)
                {
                    if (menseki[h, w] == 0)
                        ans++;
                }
            }
            Println(ans);
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static IList<string> ReadSplit() => Read().Split().ToList();
        static IList<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();

        static void Print(object value = null) => Console.Write(value.ToString());
        static void Println(object value = null) => Console.WriteLine(value.ToString());
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 13348