Module Hitachi2020B

    Sub Main()

        Dim i, j As Integer
        Dim A, B, M As Integer
        Dim x, y, c As Integer
        Dim arr(3) As String
        Dim arr_A() As Integer
        Dim arr_B() As Integer
        Dim min As Integer : min = 20000

        arr = Split(Console.ReadLine())
        A = Integer.Parse(arr(0))
        B = Integer.Parse(arr(1))
        M = Integer.Parse(arr(2))

        '冷蔵庫の読込
        ReDim arr(A - 1)
        ReDim arr_A(A - 1)
        arr = Split(Console.ReadLine())

        arr_A = Array.ConvertAll(Of String, Integer)(arr, AddressOf Integer.Parse)

        '電子レンジの読込
        ReDim arr(B - 1)
        ReDim arr_B(B - 1)
        arr = Split(Console.ReadLine())

        arr_B = Array.ConvertAll(Of String, Integer)(arr, AddressOf Integer.Parse)

        '割引を使わなかった場合の最安値を取得
        For i = 0 To A - 1
            For j = i To B - 1
                If arr_A(i) + arr_B(j) < min Then
                    min = arr_A(i) + arr_B(j)
                End If
            Next
        Next

        '割引の読込
        For i = 0 To M - 1
            arr = Split(Console.ReadLine())
            x = Integer.Parse(arr(0))
            y = Integer.Parse(arr(1))
            c = Integer.Parse(arr(2))
            If arr_A(x - 1) + arr_B(y - 1) - c < min Then
                min = arr_A(x - 1) + arr_B(y - 1) - c
            End If
        Next

        Console.Write(min)

    End Sub
End Module
