H, W, M, *hw = list(map(int, open(0).read().split()))

H_cnt = [0] * (H + 1)

W_cnt = [0] * (W + 1)

bombs = [(h, w) for h, w in zip(*[iter(hw)] * 2)]

for h, w in bombs:

    H_cnt[h] += 1

    W_cnt[w] += 1



H_max_cnt = max(H_cnt)

W_max_cnt = max(W_cnt)



H_max = {i for i in range(1, H + 1) if H_cnt[i] == H_max_cnt}

W_max = {i for i in range(1, W + 1) if W_cnt[i] == W_max_cnt}



comb_cnt = len(H_max) * len(W_max)

for h, w in bombs:

    if H_cnt[h] == H_max_cnt and W_cnt[w] == W_max_cnt:

        comb_cnt -= 1



ans = H_max_cnt + W_max_cnt

print((ans if comb_cnt else ans - 1))

H, W, M, *hw = list(map(int, open(0).read().split()))

H_cnt = [0] * (H + 1)

W_cnt = [0] * (W + 1)

bombs = [(h, w) for h, w in zip(*[iter(hw)] * 2)]

for h, w in bombs:

    H_cnt[h] += 1

    W_cnt[w] += 1



H_max_cnt = max(H_cnt)

W_max_cnt = max(W_cnt)



comb_cnt = H_cnt.count(H_max_cnt) * W_cnt.count(W_max_cnt)

for h, w in bombs:

    if H_cnt[h] == H_max_cnt and W_cnt[w] == W_max_cnt:

        comb_cnt -= 1



ans = H_max_cnt + W_max_cnt

print((ans if comb_cnt else ans - 1))

H, W, M, *hw = list(map(int, open(0).read().split()))
H_cnt = [0] * (H + 1)
W_cnt = [0] * (W + 1)
bombs = [(h, w) for h, w in zip(*[iter(hw)] * 2)]
for h, w in bombs:
    H_cnt[h] += 1
    W_cnt[w] += 1
H_max_cnt = max(H_cnt)
W_max_cnt = max(W_cnt)
H_max = {i for i in range(1, H + 1) if H_cnt[i] == H_max_cnt}
W_max = {i for i in range(1, W + 1) if W_cnt[i] == W_max_cnt}
comb_cnt = len(H_max) * len(W_max)
for h, w in bombs:
    if H_cnt[h] == H_max_cnt and W_cnt[w] == W_max_cnt:
        comb_cnt -= 1
ans = H_max_cnt + W_max_cnt
print((ans if comb_cnt else ans - 1))

H, W, M, *hw = list(map(int, open(0).read().split()))
H_cnt = [0] * (H + 1)
W_cnt = [0] * (W + 1)
bombs = [(h, w) for h, w in zip(*[iter(hw)] * 2)]
for h, w in bombs:
    H_cnt[h] += 1
    W_cnt[w] += 1
H_max_cnt = max(H_cnt)
W_max_cnt = max(W_cnt)
comb_cnt = H_cnt.count(H_max_cnt) * W_cnt.count(W_max_cnt)
for h, w in bombs:
    if H_cnt[h] == H_max_cnt and W_cnt[w] == W_max_cnt:
        comb_cnt -= 1
ans = H_max_cnt + W_max_cnt
print((ans if comb_cnt else ans - 1))

-H_max = {i for i in range(1, H + 1) if H_cnt[i] == H_max_cnt} -W_max = {i for i in range(1, W + 1) if W_cnt[i] == W_max_cnt} -comb_cnt = len(H_max) * len(W_max) +comb_cnt = H_cnt.count(H_max_cnt) * W_cnt.count(W_max_cnt)