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

namespace beginner_contest047_2
{
    class Program
    {
        static void Main(string[] args)
        {
            var whn = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();

            List<String> inputs = new List<string>();
            for(Int32 i = 0; i < whn[2]; ++i)
            {
                inputs.Add(Console.ReadLine());
            }

            var xya_list = inputs.Select(x => x.Split(' ').Select(s => Convert.ToInt32(s)).ToArray());
            var xy1 = xya_list.Where(x => x[2] == 1).Select(x => x[0]).ToArray();
            var xy2 = xya_list.Where(x => x[2] == 2).Select(x => x[0]).ToArray();
            var xy3 = xya_list.Where(x => x[2] == 3).Select(x => x[1]).ToArray();
            var xy4 = xya_list.Where(x => x[2] == 4).Select(x => x[1]).ToArray();

            var xy1v = xy1.Any() ? xy1.Max() : 0;
            var xy2v = xy2.Any() ? xy2.Min() : whn[0];
            var xy3v = xy3.Any() ? xy3.Max() : 0;
            var xy4v = xy4.Any() ? xy4.Min() : whn[1];

            var w = Math.Max(0, whn[0] - xy1v - (whn[0] - xy2v));
            var h = Math.Max(0, whn[1] - xy3v - (whn[1] - xy4v));

            Console.WriteLine(w * h);
        }
    }
}
