from collections import defaultdict

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



row = [[0, 0] for _ in range(h + 1)]

col = [[0, 0] for _ in range(w + 1)]

ex = defaultdict(bool)

for i in range(m):

    r, c = list(map(int, input().split()))

    row[r][0] += 1

    col[c][0] += 1

    row[r][1] = r

    col[c][1] = c

    ex[(r, c)] = True

row = sorted(row)[::-1]

col = sorted(col)[::-1]

ans = 0

for i in range(0, h + 1):

    for j in range(0, w + 1):

        ans = max(ans, row[i][0] + col[j][0] - ex[(row[i][1], col[j][1])])

        if not ex[(row[i][1], col[j][1])]:

            # iが同一だったら、jの値降順に見てるので木って良い

            break



print(ans)

import numpy as np

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

xy = [tuple([int(x) - 1 for x in input().split()]) for _ in range(m)]

row = np.zeros(h, np.int)

col = np.zeros(w, np.int)

for y, x in xy:

	row[y] += 1

	col[x] += 1



max_cnt_y = max(row)

max_cnt_x = max(col)

max_pair = np.sum(row == max_cnt_y) * np.sum(col == max_cnt_x)

for y, x in xy:

	if row[y] == max_cnt_y and col[x] == max_cnt_x:

		max_pair -= 1



print((max_cnt_y + max_cnt_x - (max_pair == 0)))
from collections import defaultdict

h, w, m = list(map(int, input().split()))
row = [[0, 0] for _ in range(h + 1)]
col = [[0, 0] for _ in range(w + 1)]
ex = defaultdict(bool)
for i in range(m):
    r, c = list(map(int, input().split()))
    row[r][0] += 1
    col[c][0] += 1
    row[r][1] = r
    col[c][1] = c
    ex[(r, c)] = True
row = sorted(row)[::-1]
col = sorted(col)[::-1]
ans = 0
for i in range(0, h + 1):
    for j in range(0, w + 1):
        ans = max(ans, row[i][0] + col[j][0] - ex[(row[i][1], col[j][1])])
        if not ex[(row[i][1], col[j][1])]:
            # iが同一だったら、jの値降順に見てるので木って良い
            break
print(ans)

import numpy as np

h, w, m = list(map(int, input().split()))
xy = [tuple([int(x) - 1 for x in input().split()]) for _ in range(m)]
row = np.zeros(h, np.int)
col = np.zeros(w, np.int)
for y, x in xy:
    row[y] += 1
    col[x] += 1
max_cnt_y = max(row)
max_cnt_x = max(col)
max_pair = np.sum(row == max_cnt_y) * np.sum(col == max_cnt_x)
for y, x in xy:
    if row[y] == max_cnt_y and col[x] == max_cnt_x:
        max_pair -= 1
print((max_cnt_y + max_cnt_x - (max_pair == 0)))

-from collections import defaultdict +import numpy as np -row = [[0, 0] for _ in range(h + 1)] -col = [[0, 0] for _ in range(w + 1)] -ex = defaultdict(bool) -for i in range(m): -    r, c = list(map(int, input().split())) -    row[r][0] += 1 -    col[c][0] += 1 -    row[r][1] = r -    col[c][1] = c -    ex[(r, c)] = True -row = sorted(row)[::-1] -col = sorted(col)[::-1] -ans = 0 -for i in range(0, h + 1): -    for j in range(0, w + 1): -        ans = max(ans, row[i][0] + col[j][0] - ex[(row[i][1], col[j][1])]) -        if not ex[(row[i][1], col[j][1])]: -            # iが同一だったら、jの値降順に見てるので木って良い -            break -print(ans) +xy = [tuple([int(x) - 1 for x in input().split()]) for _ in range(m)] +row = np.zeros(h, np.int) +col = np.zeros(w, np.int) +for y, x in xy: +    row[y] += 1 +    col[x] += 1 +max_cnt_y = max(row) +max_cnt_x = max(col) +max_pair = np.sum(row == max_cnt_y) * np.sum(col == max_cnt_x) +for y, x in xy: +    if row[y] == max_cnt_y and col[x] == max_cnt_x: +        max_pair -= 1 +print((max_cnt_y + max_cnt_x - (max_pair == 0)))