Imports System

Module practiceA
    Sub Main()
        Call test3()


    End Sub

    Sub test1()
        Dim K, i, A, B As Integer
        Dim arr(2) As String

        K = Console.ReadLine()
        arr = Split(Console.ReadLine())
        A = arr(0)
        B = arr(1)

        If A <= B Then

            While K * i <= 1000

                If K * i >= A And K * i <= B Then
                    Console.Write("OK")
                    Exit Sub
                Else
                    i = i + 1
                End If

            End While

        End If

        Console.Write("NG")

    End Sub

    Sub test2()
        Dim yokinn, X, year As Double

        yokinn = 100
        year = 0

        X = Console.ReadLine()

        While yokinn < X

            yokinn = Int(yokinn + yokinn * 0.01)

            year += 1

        End While

        Console.Write(year)


    End Sub

    Sub test3()
        Dim N, M, Q, i As Integer
        Dim arr2(2) As String

        Dim ar0, ar1, ar2, ar3 As Integer
        i = 0

        arr2 = Split(Console.ReadLine())
        N = arr2(0)
        M = arr2(1)
        Q = arr2(2)

        Dim A(N) As Integer
        Dim arr3(3) As String

        While i < Q
            arr3 = Split(Console.ReadLine())
            ar0 = arr3(0)
            ar1 = arr3(1)
            ar2 = arr3(2)
            ar3 = arr3(3)

            i += 1
        End While

        Console.Write(arr3(3))


    End Sub

    Sub test4()
        Dim A, B, t1, t2, max, max1 As Integer
        Dim arr2(3) As String
      Dim N, i As UInteger

        i = 0

        arr2 = Split(Console.ReadLine())
        A = arr2(0)
        B = arr2(1)
        N = arr2(2)


        While i <= N

            t1 = Int(A * i / B)
            t2 = Int(i / B)
            max = t1 - A * t2

            If max >= max1 Then
                max1 = max
            End If

            i += 1
        End While

        Console.Write(max1)


    End Sub


End Module