using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var line1 = Console.ReadLine().Split();
            int W = int.Parse(line1[0]);
            int H = int.Parse(line1[1]);
            int N = int.Parse(line1[2]);
            int minX = 0;
            int minY = 0;
            for (int i = 0; i < N; i++)
            {
                var d = Console.ReadLine().Split().Select(int.Parse).ToArray();
                switch (d[2])
                {
                    case 1:
                        minX = Math.Max(minX, d[0]);
                        break;
                    case 2:
                        W = Math.Min(W, d[0]);
                        break;
                    case 3:
                        minY = Math.Max(minY, d[1]);
                        break;
                    case 4:
                        H = Math.Min(H, d[1]);
                        break;
                }
            }
            int ans = (W - minX) * (H - minY);
            Console.WriteLine(
                ans < 0 ? 0 : ans
                );
        }
    }
}
