from collections import*

(h,w,m),*z=[tuple(map(int,o.split()))for o in open(0)]

s=set(z)

y,x=[Counter(t).most_common()for t in zip(*z)]

a,b=y[0][1],x[0][1]

p=[i for i,v in y if v==a]

q=[i for i,v in x if v==b]

for i in p:

  for j in q:

    if(i,j)not in s:exit(print(a+b))

print(a+b-1)

*r,=c=[0]*9**6

_,*z=[[*list(map(int,t.split()))]for t in open(0)]

for y,x in z:r[y]+=1;c[x]+=1

h,w=max(r),max(c)

print((h+w-(r.count(h)*c.count(w)==sum(h+w==r[y]+c[x]for y,x in z))))
from collections import *

(h, w, m), *z = [tuple(map(int, o.split())) for o in open(0)]
s = set(z)
y, x = [Counter(t).most_common() for t in zip(*z)]
a, b = y[0][1], x[0][1]
p = [i for i, v in y if v == a]
q = [i for i, v in x if v == b]
for i in p:
    for j in q:
        if (i, j) not in s:
            exit(print(a + b))
print(a + b - 1)

(*r,) = c = [0] * 9**6
_, *z = [[*list(map(int, t.split()))] for t in open(0)]
for y, x in z:
    r[y] += 1
    c[x] += 1
h, w = max(r), max(c)
print((h + w - (r.count(h) * c.count(w) == sum(h + w == r[y] + c[x] for y, x in z))))

-from collections import * - -(h, w, m), *z = [tuple(map(int, o.split())) for o in open(0)] -s = set(z) -y, x = [Counter(t).most_common() for t in zip(*z)] -a, b = y[0][1], x[0][1] -p = [i for i, v in y if v == a] -q = [i for i, v in x if v == b] -for i in p: -    for j in q: -        if (i, j) not in s: -            exit(print(a + b)) -print(a + b - 1) +(*r,) = c = [0] * 9**6 +_, *z = [[*list(map(int, t.split()))] for t in open(0)] +for y, x in z: +    r[y] += 1 +    c[x] += 1 +h, w = max(r), max(c) +print((h + w - (r.count(h) * c.count(w) == sum(h + w == r[y] + c[x] for y, x in z))))