program E176
    implicit none
    integer(4) :: H, W, M
    integer(4), allocatable, dimension(:,:) :: g
    integer(4), allocatable, dimension(:) :: nH, nW
    integer(4) :: i, j, k, l, ans
    read(5,*) H, W, M
    i = 2
    allocate(g(i,M))
    allocate(nH(H))
    allocate(nW(W))


    do i = 1, M
        read(5,*) (g(j,i), j = 1, 2)
    end do
    
    do i = 1, H
        nH(i) = 0
    end do 
    do i = 1, W
        nW(i) = 0

    end do
    do i = 1, M
        k = g(1,i)
        l = g(2,i)     
       
        nh(k) = nH(k) + 1
        nW(l) = nW(l) + 1
    end do

    k = 1
    l = 1
    do i = 2, H
        if (nH(k)<nH(i)) then 
            k = i
        end if
    end do
    do i = 2, W
        if (nW(l)<nW(i)) then 
            l = i
        end if
    end do

    ans = nH(k) + nW(l)

    do i = 1, M
        if (g(1,i)==k .and. g(2,i)==l) then
            ans = ans - 1
        end if
    end do
    write(6,*) k, l, ans
    

end program E176

