from collections import Counter


H, W, M, *hw = map(int, open(0).read().split())
h_cnt = Counter(hw[::2])
w_cnt = Counter(hw[1::2])
h_max = h_cnt.most_common(1)[0][1]
w_max = w_cnt.most_common(1)[0][1]

not_on_bomb = sum(1 for k, v in h_cnt.items() if v == h_max)
not_on_bomb *= sum(1 for k, v in w_cnt.items() if v == w_max)
for h, w in zip(*[iter(hw)] * 2):
    if h_cnt[h] == h_max and w_cnt[w] == w_max:
        not_on_bomb -= 1

ans = h_max + w_max
print(ans) if not_on_bomb else print(ans - 1) from collections import Counter H, W, M, *hw = map(int, open(0).read().split()) H map(int, open(0).read().split()) map int open(0).read().split() (0).read().split (0).read() (0).read (0) open 0 read split W M *hw hw h_cnt = Counter(hw[::2]) h_cnt Counter(hw[::2]) Counter hw[::2] hw ::2 2 w_cnt = Counter(hw[1::2]) w_cnt Counter(hw[1::2]) Counter hw[1::2] hw 1::2 1 2 h_max = h_cnt.most_common(1)[0][1] h_max h_cnt.most_common(1)[0][1] [0] h_cnt.most_common(1) h_cnt.most_common h_cnt most_common 1 0 1 w_max = w_cnt.most_common(1)[0][1] w_max w_cnt.most_common(1)[0][1] [0] w_cnt.most_common(1) w_cnt.most_common w_cnt most_common 1 0 1 not_on_bomb = sum(1 for k, v in h_cnt.items() if v == h_max) not_on_bomb sum(1 for k, v in h_cnt.items() if v == h_max) sum 1 not_on_bomb *= sum(1 for k, v in w_cnt.items() if v == w_max) not_on_bomb sum(1 for k, v in w_cnt.items() if v == w_max) sum 1 for h, w in zip(*[iter(hw)] * 2):
    if h_cnt[h] == h_max and w_cnt[w] == w_max:
        not_on_bomb -= 1 h w zip(*[iter(hw)] * 2) zip *[iter(hw)] * 2 [iter(hw)] * 2 [iter(hw)] iter(hw) iter hw 2 if h_cnt[h] == h_max and w_cnt[w] == w_max:
        not_on_bomb -= 1 h_cnt[h] == h_max and w_cnt[w] == w_max h_cnt[h] == h_max h_cnt[h] h_cnt h h_max w_cnt[w] == w_max w_cnt[w] w_cnt w w_max not_on_bomb -= 1 not_on_bomb 1 ans = h_max + w_max ans h_max + w_max h_max w_max print(ans) if not_on_bomb else print(ans - 1) not_on_bomb print(ans) print ans print(ans - 1) print ans - 1 ans 1 not_on_bomb = sum(1 for k, v in h_cnt.items() if v == h_max) sum(1 for k, v in h_cnt.items() if v == h_max) not_on_bomb ans = h_max + w_max h_max + w_max ans w_max = w_cnt.most_common(1)[0][1] w_cnt.most_common(1)[0][1] w_max not_on_bomb -= 1 1 not_on_bomb h_cnt = Counter(hw[::2]) Counter(hw[::2]) h_cnt h_max = h_cnt.most_common(1)[0][1] h_cnt.most_common(1)[0][1] h_max W, M, *hw = map(int, open(0).read().split()) map(int, open(0).read().split()) W not_on_bomb *= sum(1 for k, v in w_cnt.items() if v == w_max) sum(1 for k, v in w_cnt.items() if v == w_max) not_on_bomb w_cnt = Counter(hw[1::2]) Counter(hw[1::2]) w_cnt H, W, M, *hw = map(int, open(0).read().split()) map(int, open(0).read().split()) H M, *hw = map(int, open(0).read().split()) map(int, open(0).read().split()) M
from collections import Counter


H, W, M, *hw = map(int, open(0).read().split())
h_cnt = Counter(hw[::2])
w_cnt = Counter(hw[1::2])
h_max = h_cnt.most_common(1)[0][1]
w_max = w_cnt.most_common(1)[0][1]

not_on_bomb = sum(1 for k, v in h_cnt.items() if v == h_max)
not_on_bomb *= sum(1 for k, v in w_cnt.items() if v == w_max)
for h, w in zip(*[iter(hw)] * 2):
    if h_cnt[h] == h_max and w_cnt[w] == w_max:
        not_on_bomb -= 1

ans = h_max + w_max
print(ans) if not_on_bomb else print(ans - 1)
