PROGRAM E
  IMPLICIT NONE
  INTEGER,allocatable :: x(:),y(:)
  INTEGER,allocatable :: p(:),q(:)
  INTEGER :: h,w,m
  INTEGER :: i,j,k,tmp=0,score=0

  READ *, h,w,m
  allocate(x(m))
  allocate(y(m))
  allocate(p(h))
  allocate(q(w))
  Do i=1,m
    READ *, x(i),y(i)
  End do

  Do i=1,h
    p(i)=0
  End do
  Do i=1,w
    q(i)=0
  End do
  Do i=1,m
    Do j=1,h
    IF(x(i)==j)p(j)=p(j)+1
    End Do
  End do
  Do i=1,m
    Do j=1,w
    IF(y(i)==j)q(j)=q(j)+1
    End Do
  End do

  Do i=1,h
    Do j=i,w
      score=p(i)+q(j)
      Do k=1,m
        IF(x(k)==i .and. y(k)==j)score=score-1
      End Do
      IF(score>tmp)tmp=score
    End Do
  End Do

  deallocate(x)
  deallocate(y)
  deallocate(p)
  deallocate(q)
  Print *,tmp
END PROGRAM E
