program e176
 
implicit none
integer :: h, w, m, i, x
integer, allocatable :: eichi(:), daburyu(:)
integer, allocatable :: tate(:), yoko(:)
integer :: maxh, maxw, maxeichi, maxdaburyu
 
read *, h, w, m

allocate(eichi(1:m))
allocate(daburyu(1:m))
allocate(tate(1:h))
allocate(yoko(1:w))

do i = 1, m
 read *, eichi(i), daburyu(i)
 tate(eichi(i)) = tate(eichi(i)) + 1
 yoko(daburyu(i)) = yoko(daburyu(i)) + 1
end do

maxh = 0
maxw = 0
maxeichi = 0
maxdaburyu = 0

do i = 1, h
 if(maxh < tate(i)) then
  maxh = tate(i)
  maxeichi = i
 end if
end do
 
do i = 1, w
 if(maxw < yoko(i)) then
  maxh = yoko(i)
  maxdaburyu = i
 end if
end do

x = maxh + maxw

do i = 1, m
 if(maxeichi == eichi(i) .and. maxdaburyu == daburyu(i)) then
  x = x - 1
 end if
end do

print *, maxh, maxw

print *, x

end program e176