from collections import defaultdict



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

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

dicHW = defaultdict(set)



for h, w in HW:

  dicHW[h].add(w)



hd = defaultdict(int)

wd = defaultdict(int)



for i, j in HW:

  hd[i] += 1

  wd[j] += 1



hd = list(hd.items())

wd = list(wd.items())



hd.sort(key=lambda x: -x[1])

wd.sort(key=lambda x: -x[1])



kouhoh = []

kouhow = []



for i, j in hd:

  if j < hd[0][1]:

    break

  else:

    kouhoh.append(i)



for i, j in wd:

  if j < wd[0][1]:

    break

  else:

    kouhow.append(i)



for i in kouhoh:

  for j in kouhow:

    if j not in dicHW[i]:

      ans = hd[0][1] + wd[0][1]

      print(ans)

      exit()



ans = hd[0][1] + wd[0][1] - 1  

print(ans)

from collections import defaultdict

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



h = [0] * H

w = [0] * W



hw = defaultdict(set)



for _ in range(M):

    a,b = list(map(int,input().split()))

    h[a - 1] += 1

    w[b - 1] += 1

    hw[a - 1].add(b - 1)

    

hm = max(h)

wm = max(w)



hp = [i for i, v in enumerate(h) if v == hm]

wp = [i for i, v in enumerate(w) if v == wm]



for x in hp:

    for y in wp:

        if y not in hw[x]:

            print((hm + wm))

            exit()

else:

    print((hm + wm - 1))



from collections import defaultdict

h, w, m = list(map(int, input().split()))
HW = [list(map(int, input().split())) for _ in range(m)]
dicHW = defaultdict(set)
for h, w in HW:
    dicHW[h].add(w)
hd = defaultdict(int)
wd = defaultdict(int)
for i, j in HW:
    hd[i] += 1
    wd[j] += 1
hd = list(hd.items())
wd = list(wd.items())
hd.sort(key=lambda x: -x[1])
wd.sort(key=lambda x: -x[1])
kouhoh = []
kouhow = []
for i, j in hd:
    if j < hd[0][1]:
        break
    else:
        kouhoh.append(i)
for i, j in wd:
    if j < wd[0][1]:
        break
    else:
        kouhow.append(i)
for i in kouhoh:
    for j in kouhow:
        if j not in dicHW[i]:
            ans = hd[0][1] + wd[0][1]
            print(ans)
            exit()
ans = hd[0][1] + wd[0][1] - 1
print(ans)

from collections import defaultdict

H, W, M = list(map(int, input().split()))
h = [0] * H
w = [0] * W
hw = defaultdict(set)
for _ in range(M):
    a, b = list(map(int, input().split()))
    h[a - 1] += 1
    w[b - 1] += 1
    hw[a - 1].add(b - 1)
hm = max(h)
wm = max(w)
hp = [i for i, v in enumerate(h) if v == hm]
wp = [i for i, v in enumerate(w) if v == wm]
for x in hp:
    for y in wp:
        if y not in hw[x]:
            print((hm + wm))
            exit()
else:
    print((hm + wm - 1))

-h, w, m = list(map(int, input().split())) -HW = [list(map(int, input().split())) for _ in range(m)] -dicHW = defaultdict(set) -for h, w in HW: -    dicHW[h].add(w) -hd = defaultdict(int) -wd = defaultdict(int) -for i, j in HW: -    hd[i] += 1 -    wd[j] += 1 -hd = list(hd.items()) -wd = list(wd.items()) -hd.sort(key=lambda x: -x[1]) -wd.sort(key=lambda x: -x[1]) -kouhoh = [] -kouhow = [] -for i, j in hd: -    if j < hd[0][1]: -        break -    else: -        kouhoh.append(i) -for i, j in wd: -    if j < wd[0][1]: -        break -    else: -        kouhow.append(i) -for i in kouhoh: -    for j in kouhow: -        if j not in dicHW[i]: -            ans = hd[0][1] + wd[0][1] -            print(ans) +H, W, M = list(map(int, input().split())) +h = [0] * H +w = [0] * W +hw = defaultdict(set) +for _ in range(M): +    a, b = list(map(int, input().split())) +    h[a - 1] += 1 +    w[b - 1] += 1 +    hw[a - 1].add(b - 1) +hm = max(h) +wm = max(w) +hp = [i for i, v in enumerate(h) if v == hm] +wp = [i for i, v in enumerate(w) if v == wm] +for x in hp: +    for y in wp: +        if y not in hw[x]: +            print((hm + wm)) -ans = hd[0][1] + wd[0][1] - 1 -print(ans) +else: +    print((hm + wm - 1))