(h,w,m),*s=[[*list(map(int,i.split()))]for i in open(0)]

r,c=[0]*-~h,[0]*-~w

for x,y in s:

    r[x]+=1

    c[y]+=1

print(((R:=max(r))+(C:=max(c))-(r.count(R)*c.count(C)==sum(r[x]+c[y]==R+C for x,y in s))))

(h,w,m),*s=[[*list(map(int,i.split()))]for i in open(0)]

r,c=[0]*-~h,[0]*-~w

for x,y in s:

    r[x]+=1

    c[y]+=1

R,C=max(r),max(c)

print((R+C-(r.count(R)*c.count(C)==sum(r[x]+c[y]==R+C for x,y in s))))

(h, w, m), *s = [[*list(map(int, i.split()))] for i in open(0)]
r, c = [0] * -~h, [0] * -~w
for x, y in s:
    r[x] += 1
    c[y] += 1
print(
    (
        (R := max(r))
        + (C := max(c))
        - (r.count(R) * c.count(C) == sum(r[x] + c[y] == R + C for x, y in s))
    )
)

(h, w, m), *s = [[*list(map(int, i.split()))] for i in open(0)]
r, c = [0] * -~h, [0] * -~w
for x, y in s:
    r[x] += 1
    c[y] += 1
R, C = max(r), max(c)
print((R + C - (r.count(R) * c.count(C) == sum(r[x] + c[y] == R + C for x, y in s))))

-print( -    ( -        (R := max(r)) -        + (C := max(c)) -        - (r.count(R) * c.count(C) == sum(r[x] + c[y] == R + C for x, y in s)) -    ) -) +R, C = max(r), max(c) +print((R + C - (r.count(R) * c.count(C) == sum(r[x] + c[y] == R + C for x, y in s))))