h,w,m=list(map(int,input().split()))

item=[list(map(int,input().split())) for i in range(m)]

row=[0]*h

col=[0]*w

for i in range(m):

    x,y=item[i]

    row[x-1]+=1

    col[y-1]+=1

mr,mc=max(row),max(col)

xr=set([i for i in range(h) if row[i]==mr])

xc=set([i for i in range(w) if col[i]==mc])

check=len(xr)*len(xc)

for i in range(m):

    r,c=item[i]

    if r-1 in xr and c-1 in xc:

        check-=1

print((mr+mc if check>0 else mr+mc-1))
H, W, M = list(map(int, input().split()))

 

h = [0] * H

w = [0] * W

Mem = [tuple(map(int, input().split())) for _ in range(M) ]

for i, j in Mem:

  h[i-1] += 1

  w[j-1] += 1



maxh = max(h)

maxw = max(w)

 

listh = {i for i, v in enumerate(h, 1) if v == maxh}

listw = {j for j, v in enumerate(w, 1) if v == maxw}



cnt = len(listh) * len(listw)



for i, j in Mem:

  if i in listh and j in listw:

    cnt -= 1

 

if cnt:

  ans = maxh + maxw

else:

  ans = maxh + maxw - 1



print(ans)
h, w, m = list(map(int, input().split()))
item = [list(map(int, input().split())) for i in range(m)]
row = [0] * h
col = [0] * w
for i in range(m):
    x, y = item[i]
    row[x - 1] += 1
    col[y - 1] += 1
mr, mc = max(row), max(col)
xr = set([i for i in range(h) if row[i] == mr])
xc = set([i for i in range(w) if col[i] == mc])
check = len(xr) * len(xc)
for i in range(m):
    r, c = item[i]
    if r - 1 in xr and c - 1 in xc:
        check -= 1
print((mr + mc if check > 0 else mr + mc - 1))

H, W, M = list(map(int, input().split()))
h = [0] * H
w = [0] * W
Mem = [tuple(map(int, input().split())) for _ in range(M)]
for i, j in Mem:
    h[i - 1] += 1
    w[j - 1] += 1
maxh = max(h)
maxw = max(w)
listh = {i for i, v in enumerate(h, 1) if v == maxh}
listw = {j for j, v in enumerate(w, 1) if v == maxw}
cnt = len(listh) * len(listw)
for i, j in Mem:
    if i in listh and j in listw:
        cnt -= 1
if cnt:
    ans = maxh + maxw
else:
    ans = maxh + maxw - 1
print(ans)

-h, w, m = list(map(int, input().split())) -item = [list(map(int, input().split())) for i in range(m)] -row = [0] * h -col = [0] * w -for i in range(m): -    x, y = item[i] -    row[x - 1] += 1 -    col[y - 1] += 1 -mr, mc = max(row), max(col) -xr = set([i for i in range(h) if row[i] == mr]) -xc = set([i for i in range(w) if col[i] == mc]) -check = len(xr) * len(xc) -for i in range(m): -    r, c = item[i] -    if r - 1 in xr and c - 1 in xc: -        check -= 1 -print((mr + mc if check > 0 else mr + mc - 1)) +H, W, M = list(map(int, input().split())) +h = [0] * H +w = [0] * W +Mem = [tuple(map(int, input().split())) for _ in range(M)] +for i, j in Mem: +    h[i - 1] += 1 +    w[j - 1] += 1 +maxh = max(h) +maxw = max(w) +listh = {i for i, v in enumerate(h, 1) if v == maxh} +listw = {j for j, v in enumerate(w, 1) if v == maxw} +cnt = len(listh) * len(listw) +for i, j in Mem: +    if i in listh and j in listw: +        cnt -= 1 +if cnt: +    ans = maxh + maxw +else: +    ans = maxh + maxw - 1 +print(ans)