H,W,M = list(map(int, input().split()))



hs = [0] * H

ws = [0] * W

s = set()



for i in range(M):

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

  h -= 1

  w -= 1

  hs[h] += 1

  ws[w] += 1

  s.add((h,w))



mh = 0

mw = 0

for i in range(H):

  mh = max(mh, hs[i])

for j in range(W):

  mw = max(mw, ws[j])

  

l_s = list()

j_s = list()

for i in range(H):

  if mh == hs[i]:

    l_s.append(i)

for j in range(W):

  if mw == ws[j]:

    j_s.append(j)

    

ans = mh+mw

for i in l_s:

  for j in j_s:

    if (i,j) in s:

      continue

    print(ans)

    exit()

ans -= 1

print(ans)
H,W,M = list(map(int, input().split()))



hs = [0] * H

ws = [0] * W

s = set()

for i in range(M):

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

  h -= 1

  w -= 1

  hs[h] += 1

  ws[w] += 1

  s.add((h,w))

  

mh = 0

mw = 0

for i in range(H):

  mh = max(mh, hs[i])

for j in range(W):

  mw = max(mw, ws[j])

  

i_s = list()

j_s = list()

for i in range(H):

  if hs[i] == mh:

    i_s.append(i)

for j in range(W):

  if ws[j] == mw:

    j_s.append(j)

    

ans = mh + mw

for i in i_s:

  for j in j_s:

    if (i,j) in s:

      continue

    print(ans)

    exit()

ans -= 1

print(ans)
H, W, M = list(map(int, input().split()))
hs = [0] * H
ws = [0] * W
s = set()
for i in range(M):
    h, w = list(map(int, input().split()))
    h -= 1
    w -= 1
    hs[h] += 1
    ws[w] += 1
    s.add((h, w))
mh = 0
mw = 0
for i in range(H):
    mh = max(mh, hs[i])
for j in range(W):
    mw = max(mw, ws[j])
l_s = list()
j_s = list()
for i in range(H):
    if mh == hs[i]:
        l_s.append(i)
for j in range(W):
    if mw == ws[j]:
        j_s.append(j)
ans = mh + mw
for i in l_s:
    for j in j_s:
        if (i, j) in s:
            continue
        print(ans)
        exit()
ans -= 1
print(ans)

H, W, M = list(map(int, input().split()))
hs = [0] * H
ws = [0] * W
s = set()
for i in range(M):
    h, w = list(map(int, input().split()))
    h -= 1
    w -= 1
    hs[h] += 1
    ws[w] += 1
    s.add((h, w))
mh = 0
mw = 0
for i in range(H):
    mh = max(mh, hs[i])
for j in range(W):
    mw = max(mw, ws[j])
i_s = list()
j_s = list()
for i in range(H):
    if hs[i] == mh:
        i_s.append(i)
for j in range(W):
    if ws[j] == mw:
        j_s.append(j)
ans = mh + mw
for i in i_s:
    for j in j_s:
        if (i, j) in s:
            continue
        print(ans)
        exit()
ans -= 1
print(ans)

-l_s = list() +i_s = list() -    if mh == hs[i]: -        l_s.append(i) +    if hs[i] == mh: +        i_s.append(i) -    if mw == ws[j]: +    if ws[j] == mw: -for i in l_s: +for i in i_s: