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

namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Solve();
            System.Console.WriteLine(Result);
        }

        public static string Result { get; set; }

        private static void Solve()
        {
            var whn = Utils.ReadInts().ToArray();
            var x = new bool[whn[0]];
            var y = new bool[whn[1]];

            for (var i = 0; i < whn[2]; ++i)
            {
                var xya = Utils.ReadInts().ToArray();
                switch (xya[2])
                {
                    case 1:
                        Fill(x, xya[0], Direction.Minus);
                        break;
                    case 2:
                        Fill(x, xya[0], Direction.Plus);
                        break;
                    case 3:
                        Fill(y, xya[1], Direction.Minus);
                        break;
                    case 4:
                        Fill(y, xya[1], Direction.Plus);
                        break;
                }
            }
            // y.Select(b => b ? 'o' : 'x').ForEach(Console.WriteLine);
            // Console.Write(' ');
            // x.Select(b => b ? 'o' : 'x').ForEach(Console.Write);
            // System.Console.WriteLine();
            Result = (x.Count(b => !b) * y.Count(b => !b)).ToString();
        }

        private static void Fill(bool[] bs, int idx, Direction d)
        {
            switch (d)
            {
                case Direction.Minus:
                    Fill(bs, 0, idx - 1);
                    break;
                case Direction.Plus:
                    Fill(bs, idx, bs.Length - 1);
                    break;
            }
        }

        private static void Fill(bool[] bs, int startIndex, int endIndex)
        {
            for (var i = startIndex; i <= endIndex; ++i)
            {
                bs[i] = true;
            }
        }

        private enum Direction { Minus, Plus }
    }

    public static class Utils
    {
        #region Extensions for IO

        public static int ReadInt()
            => ReadInts().First();

        public static IEnumerable<int> ReadInts()
            => ReadStrings().Select(int.Parse);

        public static IEnumerable<String> ReadStrings()
            => Console.ReadLine().Split(' ');

        #endregion

        #region Extensions of int

        public static bool IsOdd(this int n)
            => !n.IsEven();

        public static bool IsEven(this int n)
            => n % 2 == 0;
        
        public static bool CanDivideWith(this int n, int divisor)
            => n % divisor == 0;

        #endregion

        #region Extensions of string

        public static int ToInt(this string str)
            => int.Parse(str);

        public static long ToLong(this string str)
            => long.Parse(str);

        public static bool IsNullOrEmpty(this string str)
            => string.IsNullOrEmpty(str);

        #endregion

        public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
        {
            foreach (var item in source)
            {
                action(item);
            }
        }
    }
}


Measured memory_bytes: 3032