

from collections import defaultdict



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

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

AB=[(a-1,b-1)for a,b in AB]

st=set(AB)



Wc=defaultdict(lambda :0)

Hc=defaultdict(lambda :0)

for a,b in AB:

    Hc[a]+=1

    Wc[b]+=1



Hm=max(Hc.values())

hhh=list(Hc.keys())

www=list(Wc.keys())

for i in hhh:

    if Hc[i]!=Hm:

        Hc.pop(i)

Wm=max(Wc.values())

for j in www:

    if Wc[j]!=Wm:

        Wc.pop(j)



ans=0

count=0

for i in list(Hc.keys()):

    for j in list(Wc.keys()):

        add = -1 if (i,j) in st else 0

        tmp= Hc[i] + Wc[j] + add

        ans=max(ans,tmp)

        if count>300000:

            break

        count+=1



print(ans)

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

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

HW=[(h-1,w-1)for h,w in HW]

st=set(HW)

countH=[0]*H

countW=[0]*W

for h,w in HW:

    countH[h]+=1

    countW[w]+=1

maxH=max(countH)

maxW=max(countW)

candiH=[]

candiW=[]

for i in range(H):

    if maxH==countH[i]:

        candiH.append(i)

for i in range(W):

    if maxW==countW[i]:

        candiW.append(i)

count=0

ans=maxH+maxW-1

add=0

for i in candiH:

    for j in candiW:

        if (i,j) not in st:

            add=1

        if count>300000:

            break

        count+=1

print((ans+add))
from collections import defaultdict

H, W, M = list(map(int, input().split()))
AB = [tuple(map(int, input().split())) for i in range(M)]
AB = [(a - 1, b - 1) for a, b in AB]
st = set(AB)
Wc = defaultdict(lambda: 0)
Hc = defaultdict(lambda: 0)
for a, b in AB:
    Hc[a] += 1
    Wc[b] += 1
Hm = max(Hc.values())
hhh = list(Hc.keys())
www = list(Wc.keys())
for i in hhh:
    if Hc[i] != Hm:
        Hc.pop(i)
Wm = max(Wc.values())
for j in www:
    if Wc[j] != Wm:
        Wc.pop(j)
ans = 0
count = 0
for i in list(Hc.keys()):
    for j in list(Wc.keys()):
        add = -1 if (i, j) in st else 0
        tmp = Hc[i] + Wc[j] + add
        ans = max(ans, tmp)
        if count > 300000:
            break
        count += 1
print(ans)

H, W, M = list(map(int, input().split()))
HW = [tuple(map(int, input().split())) for i in range(M)]
HW = [(h - 1, w - 1) for h, w in HW]
st = set(HW)
countH = [0] * H
countW = [0] * W
for h, w in HW:
    countH[h] += 1
    countW[w] += 1
maxH = max(countH)
maxW = max(countW)
candiH = []
candiW = []
for i in range(H):
    if maxH == countH[i]:
        candiH.append(i)
for i in range(W):
    if maxW == countW[i]:
        candiW.append(i)
count = 0
ans = maxH + maxW - 1
add = 0
for i in candiH:
    for j in candiW:
        if (i, j) not in st:
            add = 1
        if count > 300000:
            break
        count += 1
print((ans + add))

-from collections import defaultdict - -AB = [tuple(map(int, input().split())) for i in range(M)] -AB = [(a - 1, b - 1) for a, b in AB] -st = set(AB) -Wc = defaultdict(lambda: 0) -Hc = defaultdict(lambda: 0) -for a, b in AB: -    Hc[a] += 1 -    Wc[b] += 1 -Hm = max(Hc.values()) -hhh = list(Hc.keys()) -www = list(Wc.keys()) -for i in hhh: -    if Hc[i] != Hm: -        Hc.pop(i) -Wm = max(Wc.values()) -for j in www: -    if Wc[j] != Wm: -        Wc.pop(j) -ans = 0 +HW = [tuple(map(int, input().split())) for i in range(M)] +HW = [(h - 1, w - 1) for h, w in HW] +st = set(HW) +countH = [0] * H +countW = [0] * W +for h, w in HW: +    countH[h] += 1 +    countW[w] += 1 +maxH = max(countH) +maxW = max(countW) +candiH = [] +candiW = [] +for i in range(H): +    if maxH == countH[i]: +        candiH.append(i) +for i in range(W): +    if maxW == countW[i]: +        candiW.append(i) -for i in list(Hc.keys()): -    for j in list(Wc.keys()): -        add = -1 if (i, j) in st else 0 -        tmp = Hc[i] + Wc[j] + add -        ans = max(ans, tmp) +ans = maxH + maxW - 1 +add = 0 +for i in candiH: +    for j in candiW: +        if (i, j) not in st: +            add = 1 -print(ans) +print((ans + add))