from collections import defaultdict

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

r = defaultdict(int)

c = defaultdict(int)

rc = defaultdict(int)

for i in range(M):

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

    rc[(h, w)] += 1

    r[w] += 1

    c[h] += 1



ri, rmax = 0, 0

ci, cmax = 0, 0

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

    v = r[i]

    if v > rmax:

        ri = i

        rmax = v

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

    v = c[i]

    if v > cmax:

        ci = i

        cmax = v



rml, cml = [], []

for i, v in list(r.items()):

    if v == rmax:

        rml.append((i, v))

for i, v in list(c.items()):

    if v == cmax:

        cml.append((i, v))





ans = rmax+cmax-1

for i, vi in rml:

    find = False

    for j, vj in cml:

        if not (j, i) in rc:

            ans += 1

            find = True

            break

    if find:

        break

print(ans)

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

r = [0]*(W+1)

c = [0]*(H+1)

rc = {}

for i in range(M):

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

    rc[(h, w)] = True

    r[w] += 1

    c[h] += 1



rm = max(r)

cm = max(c)



ri = {i for i, v in enumerate(r) if v == rm}

ci = {i for i, v in enumerate(c) if v == cm}



cnt = sum([w in ri and h in ci for h, w in rc])

print((rm+cm-(len(ri)*len(ci) == cnt)))

from collections import defaultdict

H, W, M = list(map(int, input().split()))
r = defaultdict(int)
c = defaultdict(int)
rc = defaultdict(int)
for i in range(M):
    h, w = list(map(int, input().split()))
    rc[(h, w)] += 1
    r[w] += 1
    c[h] += 1
ri, rmax = 0, 0
ci, cmax = 0, 0
for i in list(r.keys()):
    v = r[i]
    if v > rmax:
        ri = i
        rmax = v
for i in list(c.keys()):
    v = c[i]
    if v > cmax:
        ci = i
        cmax = v
rml, cml = [], []
for i, v in list(r.items()):
    if v == rmax:
        rml.append((i, v))
for i, v in list(c.items()):
    if v == cmax:
        cml.append((i, v))
ans = rmax + cmax - 1
for i, vi in rml:
    find = False
    for j, vj in cml:
        if not (j, i) in rc:
            ans += 1
            find = True
            break
    if find:
        break
print(ans)

H, W, M = list(map(int, input().split()))
r = [0] * (W + 1)
c = [0] * (H + 1)
rc = {}
for i in range(M):
    h, w = list(map(int, input().split()))
    rc[(h, w)] = True
    r[w] += 1
    c[h] += 1
rm = max(r)
cm = max(c)
ri = {i for i, v in enumerate(r) if v == rm}
ci = {i for i, v in enumerate(c) if v == cm}
cnt = sum([w in ri and h in ci for h, w in rc])
print((rm + cm - (len(ri) * len(ci) == cnt)))

-from collections import defaultdict - -r = defaultdict(int) -c = defaultdict(int) -rc = defaultdict(int) +r = [0] * (W + 1) +c = [0] * (H + 1) +rc = {} -    rc[(h, w)] += 1 +    rc[(h, w)] = True -ri, rmax = 0, 0 -ci, cmax = 0, 0 -for i in list(r.keys()): -    v = r[i] -    if v > rmax: -        ri = i -        rmax = v -for i in list(c.keys()): -    v = c[i] -    if v > cmax: -        ci = i -        cmax = v -rml, cml = [], [] -for i, v in list(r.items()): -    if v == rmax: -        rml.append((i, v)) -for i, v in list(c.items()): -    if v == cmax: -        cml.append((i, v)) -ans = rmax + cmax - 1 -for i, vi in rml: -    find = False -    for j, vj in cml: -        if not (j, i) in rc: -            ans += 1 -            find = True -            break -    if find: -        break -print(ans) +rm = max(r) +cm = max(c) +ri = {i for i, v in enumerate(r) if v == rm} +ci = {i for i, v in enumerate(c) if v == cm} +cnt = sum([w in ri and h in ci for h, w in rc]) +print((rm + cm - (len(ri) * len(ci) == cnt)))