Option Strict On

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_A As Integer : min_A = 20000
        Dim min_B As Integer : min_B = 20000
        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
            If arr_A(i) < min_A Then
                min_A = arr_A(i)
            End If
        Next

        For i = 0 To B - 1
            If arr_B(i) < min_B Then
                min_B = arr_B(i)
            End If
        Next
        min = min_A + min_B

        '割引の読込
        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
