program main
  implicit none
  integer ::  M
  integer, allocatable :: a(:),b(:),x(:),y(:),c(:)
  integer :: i,j
  integer :: min_tmp,tmp
  read(*,*) i, j, M
  allocate(a(i),b(j))

  read(*,*) a
  read(*,*) b
  allocate( x(M), y(M), c(M))
  do i = 1, M
     read(*,*) x(i), y(i),c(i)
  end do

  min_tmp = minval(a) + minval(b)
  do i = 1,M
     tmp = a(x(i)) + b(y(i)) -c(i)
     if (min_tmp > tmp ) then
        min_tmp = tmp
     end if
  end do

  write(*,'(i0)') min_tmp

end program main
