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

namespace ABC047B
{
    class Program
    {
        static void Solve(Input input)
        {
            var w = input.NextInt();
            var h = input.NextInt();
            var n = input.NextInt();

            // 0: white
            var map = new int[h, w];

            for (int i = 0; i < n; i++)
            {
                var x = input.NextInt();
                var y = input.NextInt();
                var a = input.NextInt();

                int ydir = 1;
                int xdir = 1;

                if (a == 1)
                {
                    // x以下を塗りつぶし
                    xdir = -1;
                    y = -1;
                }
                else if (a == 2)
                {
                    // xを超える範囲を塗りつぶし
                    xdir = 1;
                    x -= xdir;
                    y = -1;
                }
                else if (a == 3)
                {
                    // y以下を塗りつぶし
                    ydir = -1;
                    x = -1;
                }
                else if (a == 4)
                {
                    // yを超える範囲を塗りつぶし
                    ydir = 1;
                    y -= ydir;
                    x = -1;
                }

                for (int j = y + ydir; 0 <= j && j < h; j += ydir)
                {
                    for (int k = x + xdir; 0 <= k && k < w; k += xdir)
                    {
                        map[j, k] = 1;
                    }
                }
            }

            int count = 0;
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    if (map[i, j] == 0) count++;
                }
            }

            Console.WriteLine(count);
        }

        #region Competitive Template
        public static void Main(string[] args)
        {
            var needsFlushOutput = true;
            if (needsFlushOutput)
            {
                // 細かく出力しないようにする
                var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
                Console.SetOut(sw);
            }

            // 通常は引数無しで、ファイルから読み出したい場合はpath指定する
            var input = new Input();
            // 仮想的に標準入力をセットする
            //input.SetText("");

            Solve(input);

            Console.Out.Flush();
        }

        class Input
        {
            // 変な改行コードがたまに混じっているので、一応セパレート指定する
            static readonly char[] separator = { ' ', '\r', '\n' };
            public bool IsEof { get; set; }
            Queue<string> q { get; set; }
            StreamReader sr;

            public Input(string path = "")
            {
                IsEof = false;
                q = new Queue<string>();

                if (string.IsNullOrEmpty(path))
                {
                    sr = new StreamReader(Console.OpenStandardInput());
                }
                else
                {
                    sr = new StreamReader(path);
                }
            }

            /// <summary>
            /// 入力予約
            /// </summary>
            /// <param name="items"></param>
            public void SetText(IEnumerable<string> items)
            {
                foreach (var item in items)
                {
                    SetText(item);
                }
            }

            /// <summary>
            /// 入力予約
            /// </summary>
            /// <param name="s"></param>
            /// <returns></returns>
            public bool SetText(string s)
            {
                if (s == null) return false;

                foreach (var elem in s.Trim().Split(separator, StringSplitOptions.RemoveEmptyEntries))
                {
                    q.Enqueue(elem);
                }

                return true;
            }

            /// <summary>
            /// 内部queueに入力からの値をsplitして格納する
            /// </summary>
            /// <returns></returns>
            bool read()
            {
                var s = sr.ReadLine();
                if (s == null) return false;

                foreach (var elem in s.Trim().Split(separator, StringSplitOptions.RemoveEmptyEntries))
                {
                    q.Enqueue(elem);
                }

                if (!q.Any()) return read();

                return true;
            }

            /// <summary>
            /// 次のstringを一つ読み込む
            /// </summary>
            /// <returns></returns>
            public string Next()
            {
                if (!q.Any())
                {
                    if (!read())
                    {
                        IsEof = true;
                        return "";
                    }
                }

                return q.Dequeue();
            }

            public int NextInt() => int.Parse(Next());
            public long NextLong() => long.Parse(Next());
            public double NextDouble() => double.Parse(Next());

            public string[] Next(int n) => Enumerable.Range(0, n).Select(_ => Next()).ToArray();
            public int[] NextInt(int n) => Next(n).Select(x => int.Parse(x)).ToArray();
            public long[] NextLong(int n) => Next(n).Select(x => long.Parse(x)).ToArray();
            public double[] NextDouble(int n) => Next(n).Select(x => double.Parse(x)).ToArray();
        }

        static class Utils
        {
            public static void Print<T>(IEnumerable<T> ie, string sep = " ") => Console.WriteLine(string.Join(sep, ie));
            public static void Print<T>(params T[] objs) => Print(objs);
            public static T Max<T>(params T[] objs) => objs.Max();
            public static T Min<T>(params T[] objs) => objs.Min();

            public static void Swap<T>(ref T x, ref T y) where T : struct { var t = x; x = y; y = t; }
            public static void Swap<T>(IList<T> list, int i, int j) where T : struct { var t = list[i]; list[i] = list[j]; list[j] = t; }

        }
        #endregion
    }
}


Measured memory_bytes: 13348