from itertools import chain
from bisect import bisect_left, bisect_right

H, W, M = map(int, input().split())
YX = [list(map(int, input().split())) for _ in range(M)]
# H, W, M = 3*10**5, 3*10**5, 3*10**5
# YX = [[(i*100)//W, (i*100)%W] for i in range(M)]

X_sets = [[] for _ in range(W+1)]
Y_sets = [[] for _ in range(H+1)]
for y, x in YX:
    X_sets[x].append(y)
    Y_sets[y].append(x)

[s.sort() for s in X_sets]
[s.sort() for s in Y_sets]

# print(X_sets, Y_sets)

X_set_max_len = max(map(len, X_sets))
Y_set_max_len = max(map(len, Y_sets))

# print("ppp", X_set_max_len, Y_set_max_len)

# for s in X_sets:
#     print(s)

X_list = set(i for i, s in enumerate(X_sets) if len(s) == X_set_max_len)
Y_list = set(i for i, s in enumerate(Y_sets) if len(s) == Y_set_max_len)

score = X_set_max_len + Y_set_max_len - 1
# print("b", score, X_list, Y_list)
for x in X_list:
    for y in Y_list:
        c = bisect_right(X_sets[x], y) - bisect_left(X_sets[x], y)
        # print(x, y, c)
        if c == 0:
            score += 1
            print(score)
            exit()

print(score) from itertools import chain from bisect import bisect_left, bisect_right H, W, M = map(int, input().split()) H map(int, input().split()) map int input().split() ().split () input split W M list(map(int, input().split())) for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split YX = [list(map(int, input().split())) for _ in range(M)] YX [list(map(int, input().split())) for _ in range(M)] [] for _ in range(W+1) for _ in range(W+1) _ range(W+1) range W+1 W 1 for _ in range(W+1) [] X_sets = [[] for _ in range(W+1)] X_sets [[] for _ in range(W+1)] [] for _ in range(H+1) for _ in range(H+1) _ range(H+1) range H+1 H 1 for _ in range(H+1) [] Y_sets = [[] for _ in range(H+1)] Y_sets [[] for _ in range(H+1)] for y, x in YX:
    X_sets[x].append(y)
    Y_sets[y].append(x) y x YX X_sets[x].append(y) [x].append [x] X_sets x append y Y_sets[y].append(x) [y].append [y] Y_sets y append x s.sort() for s in X_sets for s in X_sets s X_sets for s in X_sets s.sort() s.sort s sort [s.sort() for s in X_sets] s.sort() for s in Y_sets for s in Y_sets s Y_sets for s in Y_sets s.sort() s.sort s sort [s.sort() for s in Y_sets] X_set_max_len = max(map(len, X_sets)) X_set_max_len max(map(len, X_sets)) max map(len, X_sets) map len X_sets Y_set_max_len = max(map(len, Y_sets)) Y_set_max_len max(map(len, Y_sets)) max map(len, Y_sets) map len Y_sets X_list = set(i for i, s in enumerate(X_sets) if len(s) == X_set_max_len) X_list set(i for i, s in enumerate(X_sets) if len(s) == X_set_max_len) set i Y_list = set(i for i, s in enumerate(Y_sets) if len(s) == Y_set_max_len) Y_list set(i for i, s in enumerate(Y_sets) if len(s) == Y_set_max_len) set i score = X_set_max_len + Y_set_max_len - 1 score X_set_max_len + Y_set_max_len - 1 X_set_max_len + Y_set_max_len X_set_max_len Y_set_max_len 1 for x in X_list:
    for y in Y_list:
        c = bisect_right(X_sets[x], y) - bisect_left(X_sets[x], y)
        # print(x, y, c)
        if c == 0:
            score += 1
            print(score)
            exit() x X_list for y in Y_list:
        c = bisect_right(X_sets[x], y) - bisect_left(X_sets[x], y)
        # print(x, y, c)
        if c == 0:
            score += 1
            print(score)
            exit() y Y_list c = bisect_right(X_sets[x], y) - bisect_left(X_sets[x], y) c bisect_right(X_sets[x], y) - bisect_left(X_sets[x], y) bisect_right(X_sets[x], y) bisect_right X_sets[x] X_sets x y bisect_left(X_sets[x], y) bisect_left X_sets[x] X_sets x y if c == 0:
            score += 1
            print(score)
            exit() c == 0 c 0 score += 1 score 1 print(score) print score exit() exit print(score) print score W, M = map(int, input().split()) map(int, input().split()) W Y_sets = [[] for _ in range(H+1)] [[] for _ in range(H+1)] Y_sets X_sets = [[] for _ in range(W+1)] [[] for _ in range(W+1)] X_sets H, W, M = map(int, input().split()) map(int, input().split()) H score += 1 1 score YX = [list(map(int, input().split())) for _ in range(M)] [list(map(int, input().split())) for _ in range(M)] YX c = bisect_right(X_sets[x], y) - bisect_left(X_sets[x], y) bisect_right(X_sets[x], y) - bisect_left(X_sets[x], y) c Y_set_max_len = max(map(len, Y_sets)) max(map(len, Y_sets)) Y_set_max_len Y_list = set(i for i, s in enumerate(Y_sets) if len(s) == Y_set_max_len) set(i for i, s in enumerate(Y_sets) if len(s) == Y_set_max_len) Y_list M = map(int, input().split()) map(int, input().split()) M X_list = set(i for i, s in enumerate(X_sets) if len(s) == X_set_max_len) set(i for i, s in enumerate(X_sets) if len(s) == X_set_max_len) X_list score = X_set_max_len + Y_set_max_len - 1 X_set_max_len + Y_set_max_len - 1 score X_set_max_len = max(map(len, X_sets)) max(map(len, X_sets)) X_set_max_len
from itertools import chain
from bisect import bisect_left, bisect_right

H, W, M = map(int, input().split())
YX = [list(map(int, input().split())) for _ in range(M)]
# H, W, M = 3*10**5, 3*10**5, 3*10**5
# YX = [[(i*100)//W, (i*100)%W] for i in range(M)]

X_sets = [[] for _ in range(W+1)]
Y_sets = [[] for _ in range(H+1)]
for y, x in YX:
    X_sets[x].append(y)
    Y_sets[y].append(x)

[s.sort() for s in X_sets]
[s.sort() for s in Y_sets]

# print(X_sets, Y_sets)

X_set_max_len = max(map(len, X_sets))
Y_set_max_len = max(map(len, Y_sets))

# print("ppp", X_set_max_len, Y_set_max_len)

# for s in X_sets:
#     print(s)

X_list = set(i for i, s in enumerate(X_sets) if len(s) == X_set_max_len)
Y_list = set(i for i, s in enumerate(Y_sets) if len(s) == Y_set_max_len)

score = X_set_max_len + Y_set_max_len - 1
# print("b", score, X_list, Y_list)
for x in X_list:
    for y in Y_list:
        c = bisect_right(X_sets[x], y) - bisect_left(X_sets[x], y)
        # print(x, y, c)
        if c == 0:
            score += 1
            print(score)
            exit()

print(score)