Option Strict On
Imports System.Console
Imports System.Collections.Generic

Module Program

    Sub Main()
        Dim w As Integer = NextInt()
        Dim h As Integer = NextInt()
        Dim n As Integer = NextInt()
        Dim arr As Integer(,) = New Integer(h - 1, w - 1) {}

        For i As Integer = 0 To h - 1
            For j As Integer = 0 To w - 1
                arr(i, j) = 1
            Next
        Next

        Dim ans As Integer = 0

        For i As Integer = n - 1 To 0 Step -1
            Dim xi As Integer = NextInt()
            Dim yi As Integer = NextInt()
            Dim a As Integer = NextInt()

            For y As Integer = 0 To h - 1
                For x As Integer = 0 To w - 1
                    Select Case True
                        Case a = 1 AndAlso x < xi
                            arr(y, x) = 0
                        Case a = 2 AndAlso x >= xi
                            arr(y, x) = 0
                        Case a = 3 AndAlso y < yi
                            arr(y, x) = 0
                        Case a = 4 AndAlso y >= yi
                            arr(y, x) = 0
                    End Select

                    If i = 0 Then ans += arr(y, x)
                Next
            Next
        Next

        WriteLine(ans)
    End Sub

    Function B2i(ok As Boolean) As Integer
        If ok Then Return 1
        Return 0
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of String)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return String.Join("", result)
    End Function

End Module
