from sys import exit, stdin



# import copy

from collections import deque, Counter



# import numpy as np

input = stdin.readline



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



col = Counter()

row = Counter()

D = Counter()

for i in range(M):

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

    row.update([h])

    col.update([w])

    D.update([str(h) + str(w)])



# rmax = row.most_common(1)

# cmax = col.most_common(1)

# idx = str(rmax[0][0]) + str(cmax[0][0])

# p = D[idx]



# ans = rmax[0][1] + cmax[0][1] - p



rtmp = row.most_common(1)[0][1]

ctmp = col.most_common(1)[0][1]

rmax = []

cmax = []



for r in row.most_common():

    if r[1] < rtmp:

        break

    rmax.append(r)



for c in col.most_common():

    if c[1] < ctmp:

        break

    cmax.append(c)



ridx = str(rmax[0][0])

for d in cmax:

    if D[ridx + str(d[0])] == 0:

        ans = rmax[0][1] + d[1]

        break

else:

    ans = rmax[0][1] + d[1] - 1



cidx = str(cmax[0][0])

for d in rmax:

    if D[str(d[0]) + cidx] == 0:

        ans2 = cmax[0][1] + d[1]

        break

else:

    ans2 = cmax[0][1] + d[1] - 1



print((max(ans, ans2)))



from sys import exit, stdin



# import copy

from collections import deque, Counter



# import numpy as np

input = stdin.readline



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



col = Counter()

row = Counter()

D = Counter()

for i in range(M):

    h, w = input().split()

    row.update([h])

    col.update([w])

    D.update([h + w])



rtop = row.most_common(1)[0]

ctop = col.most_common(1)[0]





for c in col.most_common():

    if c[1] < ctop[1]:

        break

    else:

        if D[rtop[0] + c[0]] == 0:

            ans = rtop[1] + c[1]

            break

        else:

            ans = rtop[1] + c[1] - 1



for r in row.most_common():

    if r[1] < rtop[1]:

        break

    else:

        if D[r[0] + ctop[0]] == 0:

            ans2 = r[1] + ctop[1]

            break

        else:

            ans2 = r[1] + c[1] - 1



print((max(ans, ans2)))



from sys import exit, stdin

# import copy
from collections import deque, Counter

# import numpy as np
input = stdin.readline
H, W, M = list(map(int, input().split()))
col = Counter()
row = Counter()
D = Counter()
for i in range(M):
    h, w = list(map(int, input().split()))
    row.update([h])
    col.update([w])
    D.update([str(h) + str(w)])
# rmax = row.most_common(1)
# cmax = col.most_common(1)
# idx = str(rmax[0][0]) + str(cmax[0][0])
# p = D[idx]
# ans = rmax[0][1] + cmax[0][1] - p
rtmp = row.most_common(1)[0][1]
ctmp = col.most_common(1)[0][1]
rmax = []
cmax = []
for r in row.most_common():
    if r[1] < rtmp:
        break
    rmax.append(r)
for c in col.most_common():
    if c[1] < ctmp:
        break
    cmax.append(c)
ridx = str(rmax[0][0])
for d in cmax:
    if D[ridx + str(d[0])] == 0:
        ans = rmax[0][1] + d[1]
        break
else:
    ans = rmax[0][1] + d[1] - 1
cidx = str(cmax[0][0])
for d in rmax:
    if D[str(d[0]) + cidx] == 0:
        ans2 = cmax[0][1] + d[1]
        break
else:
    ans2 = cmax[0][1] + d[1] - 1
print((max(ans, ans2)))

from sys import exit, stdin

# import copy
from collections import deque, Counter

# import numpy as np
input = stdin.readline
H, W, M = list(map(int, input().split()))
col = Counter()
row = Counter()
D = Counter()
for i in range(M):
    h, w = input().split()
    row.update([h])
    col.update([w])
    D.update([h + w])
rtop = row.most_common(1)[0]
ctop = col.most_common(1)[0]
for c in col.most_common():
    if c[1] < ctop[1]:
        break
    else:
        if D[rtop[0] + c[0]] == 0:
            ans = rtop[1] + c[1]
            break
        else:
            ans = rtop[1] + c[1] - 1
for r in row.most_common():
    if r[1] < rtop[1]:
        break
    else:
        if D[r[0] + ctop[0]] == 0:
            ans2 = r[1] + ctop[1]
            break
        else:
            ans2 = r[1] + c[1] - 1
print((max(ans, ans2)))

-    h, w = list(map(int, input().split())) +    h, w = input().split() -    D.update([str(h) + str(w)]) -# rmax = row.most_common(1) -# cmax = col.most_common(1) -# idx = str(rmax[0][0]) + str(cmax[0][0]) -# p = D[idx] -# ans = rmax[0][1] + cmax[0][1] - p -rtmp = row.most_common(1)[0][1] -ctmp = col.most_common(1)[0][1] -rmax = [] -cmax = [] +    D.update([h + w]) +rtop = row.most_common(1)[0] +ctop = col.most_common(1)[0] +for c in col.most_common(): +    if c[1] < ctop[1]: +        break +    else: +        if D[rtop[0] + c[0]] == 0: +            ans = rtop[1] + c[1] +            break +        else: +            ans = rtop[1] + c[1] - 1 -    if r[1] < rtmp: +    if r[1] < rtop[1]: -    rmax.append(r) -for c in col.most_common(): -    if c[1] < ctmp: -        break -    cmax.append(c) -ridx = str(rmax[0][0]) -for d in cmax: -    if D[ridx + str(d[0])] == 0: -        ans = rmax[0][1] + d[1] -        break -else: -    ans = rmax[0][1] + d[1] - 1 -cidx = str(cmax[0][0]) -for d in rmax: -    if D[str(d[0]) + cidx] == 0: -        ans2 = cmax[0][1] + d[1] -        break -else: -    ans2 = cmax[0][1] + d[1] - 1 +    else: +        if D[r[0] + ctop[0]] == 0: +            ans2 = r[1] + ctop[1] +            break +        else: +            ans2 = r[1] + c[1] - 1