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



hc = [0] * H

wc = [0] * W

d = {}

for _ in range(M):

    h, w = [int(x) - 1 for x in input().split()]

    hc[h] += 1

    wc[w] += 1

    d.setdefault(h, {})

    d[h][w] = 1



result = 0

hm = max(hc)

wm = max(wc)

hi = [i for i in range(H) if hc[i] == hm]

wi = [i for i in range(W) if wc[i] == wm]



for h in hi:

    for w in wi:

        if h in d and w in d[h]:

            result = max(result, hm + wm - 1)

        else:

            result = max(result, hm + wm)

            break

print(result)

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



hc = [0] * H

wc = [0] * W

d = {}

for _ in range(M):

    h, w = [int(x) - 1 for x in input().split()]

    hc[h] += 1

    wc[w] += 1

    d[(h, w)] = 1



maxh = max(hc)

maxw = max(wc)



result = max(maxh + maxw - 1, 0)

wi = [i for i in range(W) if wc[i] == maxw]

for h in [i for i in range(H) if hc[i] == maxh]:

    for w in wi:

        if (h, w) not in d:

            result = maxh + maxw

            break

print(result)

H, W, M = list(map(int, input().split()))
hc = [0] * H
wc = [0] * W
d = {}
for _ in range(M):
    h, w = [int(x) - 1 for x in input().split()]
    hc[h] += 1
    wc[w] += 1
    d.setdefault(h, {})
    d[h][w] = 1
result = 0
hm = max(hc)
wm = max(wc)
hi = [i for i in range(H) if hc[i] == hm]
wi = [i for i in range(W) if wc[i] == wm]
for h in hi:
    for w in wi:
        if h in d and w in d[h]:
            result = max(result, hm + wm - 1)
        else:
            result = max(result, hm + wm)
            break
print(result)

H, W, M = list(map(int, input().split()))
hc = [0] * H
wc = [0] * W
d = {}
for _ in range(M):
    h, w = [int(x) - 1 for x in input().split()]
    hc[h] += 1
    wc[w] += 1
    d[(h, w)] = 1
maxh = max(hc)
maxw = max(wc)
result = max(maxh + maxw - 1, 0)
wi = [i for i in range(W) if wc[i] == maxw]
for h in [i for i in range(H) if hc[i] == maxh]:
    for w in wi:
        if (h, w) not in d:
            result = maxh + maxw
            break
print(result)

-    d.setdefault(h, {}) -    d[h][w] = 1 -result = 0 -hm = max(hc) -wm = max(wc) -hi = [i for i in range(H) if hc[i] == hm] -wi = [i for i in range(W) if wc[i] == wm] -for h in hi: +    d[(h, w)] = 1 +maxh = max(hc) +maxw = max(wc) +result = max(maxh + maxw - 1, 0) +wi = [i for i in range(W) if wc[i] == maxw] +for h in [i for i in range(H) if hc[i] == maxh]: -        if h in d and w in d[h]: -            result = max(result, hm + wm - 1) -        else: -            result = max(result, hm + wm) +        if (h, w) not in d: +            result = maxh + maxw