import sys



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

R = [0] * H

C = [0] * W



S = set()



for _ in range(M):

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

    S.add((h-1, w-1))

    R[h-1] += 1

    C[w-1] += 1



r = max(R)

c = max(C)



HL = [i for i in range(H) if R[i] == r]

WL = [i for i in range(W) if C[i] == c]



for h in HL:

    for w in WL:

        if not (h, w) in S:

            print((r + c))

            sys.exit()



print((r + c - 1))
H, W, M = list(map(int,input().split()))

R = [0] * H

C = [0] * W



L = []



for _ in range(M):

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

    R[h-1] += 1

    C[w-1] += 1

    L.append([h-1, w-1])



r = max(R)

c = max(C)



print((r + c - (R.count(r) * C.count(c) == sum(R[h] + C[w] == r + c for h, w in L))))
import sys

H, W, M = list(map(int, input().split()))
R = [0] * H
C = [0] * W
S = set()
for _ in range(M):
    h, w = list(map(int, input().split()))
    S.add((h - 1, w - 1))
    R[h - 1] += 1
    C[w - 1] += 1
r = max(R)
c = max(C)
HL = [i for i in range(H) if R[i] == r]
WL = [i for i in range(W) if C[i] == c]
for h in HL:
    for w in WL:
        if not (h, w) in S:
            print((r + c))
            sys.exit()
print((r + c - 1))

H, W, M = list(map(int, input().split()))
R = [0] * H
C = [0] * W
L = []
for _ in range(M):
    h, w = list(map(int, input().split()))
    R[h - 1] += 1
    C[w - 1] += 1
    L.append([h - 1, w - 1])
r = max(R)
c = max(C)
print((r + c - (R.count(r) * C.count(c) == sum(R[h] + C[w] == r + c for h, w in L))))

-import sys - -S = set() +L = [] -    S.add((h - 1, w - 1)) +    L.append([h - 1, w - 1]) -HL = [i for i in range(H) if R[i] == r] -WL = [i for i in range(W) if C[i] == c] -for h in HL: -    for w in WL: -        if not (h, w) in S: -            print((r + c)) -            sys.exit() -print((r + c - 1)) +print((r + c - (R.count(r) * C.count(c) == sum(R[h] + C[w] == r + c for h, w in L))))