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

Module Program

    Sub Main()
        Dim w As Integer = NextInt()
        Dim h As Integer = NextInt()
        Dim n As Integer = NextInt()

        Dim x As Integer = 0
        Dim y As Integer = 0

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

            Select Case a
                Case 1
                    x = Max(x, xi)
                Case 2
                    w = Min(w, xi)
                Case 3
                    y = Max(y, yi)
                Case 4
                    h = Min(h, yi)
            End Select
        Next

        WriteLine(Max(0, w - x) * Max(0, h - y))
    End Sub

    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
