import time



t0 = time.time()



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

H = [0]*(h+1)

W = [0]*(w+1)

s = set([])

for i in range(m):

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

    s.add((a,b))



    H[a] += 1

    W[b] += 1



x = [0]*(h+1)

y = [0]*(w+1)

    

for i in range(h+1):

    x[i] = [i,H[i]]

for i in range(w+1):

    y[i] = [i,W[i]]



x.sort(key= lambda val : val[1],reverse=True)

y.sort(key= lambda val : val[1],reverse=True)



ma = x[0][1]

mb = y[0][1]



i,j = 0,0

sw = 0

while 1:

    if j > w:

        break

    if  x[i][1] == ma:

        if (x[i][0],y[j][0]) in s:

            pass

        else:

            if x[i][1]+y[j][1] == ma+mb:

                sw = 1

                break

        i += 1

    else:

        i = 0

        j += 1

    if time.time() - t0 > 2.5:

        break



    

print((ma+mb+sw-1))

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

s = set([])

H = [0]*(h+1)

W = [0]*(w+1)

for i in range(m):

    x,y = list(map(int,input().split()))

    H[x] += 1

    W[y] += 1

    s.add((x,y))

    

p = [0]*(h+1)

q = [0]*(w+1)

for i in range(h+1):

    p[i] = [i, H[i]]

for i in range(w+1):

    q[i] = [i, W[i]]

    

p.sort(key= lambda val : val[1],reverse=True)

q.sort(key= lambda val : val[1],reverse=True)



mh = max(H)

mw = max(W)

I = H.count(mh)

J = W.count(mw)



sw = 0

for i in range(I):

    if sw == 1:

        break

    for j in range(J):

        if (p[i][0], q[j][0]) in s:

            pass

        else:

            sw = 1

            break



print((mh+mw-1+sw))

import time

t0 = time.time()
h, w, m = list(map(int, input().split()))
H = [0] * (h + 1)
W = [0] * (w + 1)
s = set([])
for i in range(m):
    a, b = list(map(int, input().split()))
    s.add((a, b))
    H[a] += 1
    W[b] += 1
x = [0] * (h + 1)
y = [0] * (w + 1)
for i in range(h + 1):
    x[i] = [i, H[i]]
for i in range(w + 1):
    y[i] = [i, W[i]]
x.sort(key=lambda val: val[1], reverse=True)
y.sort(key=lambda val: val[1], reverse=True)
ma = x[0][1]
mb = y[0][1]
i, j = 0, 0
sw = 0
while 1:
    if j > w:
        break
    if x[i][1] == ma:
        if (x[i][0], y[j][0]) in s:
            pass
        else:
            if x[i][1] + y[j][1] == ma + mb:
                sw = 1
                break
        i += 1
    else:
        i = 0
        j += 1
    if time.time() - t0 > 2.5:
        break
print((ma + mb + sw - 1))

h, w, m = list(map(int, input().split()))
s = set([])
H = [0] * (h + 1)
W = [0] * (w + 1)
for i in range(m):
    x, y = list(map(int, input().split()))
    H[x] += 1
    W[y] += 1
    s.add((x, y))
p = [0] * (h + 1)
q = [0] * (w + 1)
for i in range(h + 1):
    p[i] = [i, H[i]]
for i in range(w + 1):
    q[i] = [i, W[i]]
p.sort(key=lambda val: val[1], reverse=True)
q.sort(key=lambda val: val[1], reverse=True)
mh = max(H)
mw = max(W)
I = H.count(mh)
J = W.count(mw)
sw = 0
for i in range(I):
    if sw == 1:
        break
    for j in range(J):
        if (p[i][0], q[j][0]) in s:
            pass
        else:
            sw = 1
            break
print((mh + mw - 1 + sw))

-import time - -t0 = time.time() +s = set([]) -s = set([]) -    a, b = list(map(int, input().split())) -    s.add((a, b)) -    H[a] += 1 -    W[b] += 1 -x = [0] * (h + 1) -y = [0] * (w + 1) +    x, y = list(map(int, input().split())) +    H[x] += 1 +    W[y] += 1 +    s.add((x, y)) +p = [0] * (h + 1) +q = [0] * (w + 1) -    x[i] = [i, H[i]] +    p[i] = [i, H[i]] -    y[i] = [i, W[i]] -x.sort(key=lambda val: val[1], reverse=True) -y.sort(key=lambda val: val[1], reverse=True) -ma = x[0][1] -mb = y[0][1] -i, j = 0, 0 +    q[i] = [i, W[i]] +p.sort(key=lambda val: val[1], reverse=True) +q.sort(key=lambda val: val[1], reverse=True) +mh = max(H) +mw = max(W) +I = H.count(mh) +J = W.count(mw) -while 1: -    if j > w: +for i in range(I): +    if sw == 1: -    if x[i][1] == ma: -        if (x[i][0], y[j][0]) in s: +    for j in range(J): +        if (p[i][0], q[j][0]) in s: -            if x[i][1] + y[j][1] == ma + mb: -                sw = 1 -                break -        i += 1 -    else: -        i = 0 -        j += 1 -    if time.time() - t0 > 2.5: -        break -print((ma + mb + sw - 1)) +            sw = 1 +            break +print((mh + mw - 1 + sw))