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

HW = set()

for _ in range(m):

    x, y = list(map(int, input().split()))

    HW.add((x-1,y-1))



sum_h = [[0,0] for _ in range(h)] # [sum, index]

sum_w = [[0,0] for _ in range(w)]

for h,w in HW:

    sum_h[h][0] += 1

    sum_w[w][0] += 1

    sum_h[h][1] = h

    sum_w[w][1] = w



h_num_ix = {}

for num,ix in sum_h:

    if not num in h_num_ix:

        h_num_ix[num] = set()

    h_num_ix[num].add(ix)



w_num_ix = {}

for num,ix in sum_w:

    if not num in w_num_ix:

        w_num_ix[num] = set()

    w_num_ix[num].add(ix)



max_h_num = max(h_num_ix)

max_w_num = max(w_num_ix)



max_num = max_h_num + max_w_num - 1

for h_ix in h_num_ix[max_h_num]:

    for w_ix in w_num_ix[max_w_num]:

        num = max_h_num + max_w_num

        if (h_ix, w_ix) in HW: continue

        max_num += 1

        print(max_num)

        exit()

print(max_num)

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

HW = set(tuple([int(x)-1 for x in input().split()]) for _ in range(M))



sum_h = [0]*H; sum_w = [0]*W

for h, w in HW:

    sum_h[h] += 1

    sum_w[w] += 1



h_num_ix = {}

for i in range(H):

    num = sum_h[i]

    if num == 0: continue

    if not num in h_num_ix: h_num_ix[num] = set()

    h_num_ix[num].add(i)



w_num_ix = {}

for i in range(W):

    num = sum_w[i]

    if num == 0: continue

    if not num in w_num_ix: w_num_ix[num] = set()

    w_num_ix[num].add(i)



max_h_num = max(h_num_ix)

max_w_num = max(w_num_ix)



max_num = max_h_num + max_w_num - 1

for h_ix in h_num_ix[max_h_num]:

    for w_ix in w_num_ix[max_w_num]:

        if (h_ix, w_ix) in HW: continue

        print((max_num + 1))

        exit()

print(max_num)

h, w, m = list(map(int, input().split()))
HW = set()
for _ in range(m):
    x, y = list(map(int, input().split()))
    HW.add((x - 1, y - 1))
sum_h = [[0, 0] for _ in range(h)]  # [sum, index]
sum_w = [[0, 0] for _ in range(w)]
for h, w in HW:
    sum_h[h][0] += 1
    sum_w[w][0] += 1
    sum_h[h][1] = h
    sum_w[w][1] = w
h_num_ix = {}
for num, ix in sum_h:
    if not num in h_num_ix:
        h_num_ix[num] = set()
    h_num_ix[num].add(ix)
w_num_ix = {}
for num, ix in sum_w:
    if not num in w_num_ix:
        w_num_ix[num] = set()
    w_num_ix[num].add(ix)
max_h_num = max(h_num_ix)
max_w_num = max(w_num_ix)
max_num = max_h_num + max_w_num - 1
for h_ix in h_num_ix[max_h_num]:
    for w_ix in w_num_ix[max_w_num]:
        num = max_h_num + max_w_num
        if (h_ix, w_ix) in HW:
            continue
        max_num += 1
        print(max_num)
        exit()
print(max_num)

H, W, M = list(map(int, input().split()))
HW = set(tuple([int(x) - 1 for x in input().split()]) for _ in range(M))
sum_h = [0] * H
sum_w = [0] * W
for h, w in HW:
    sum_h[h] += 1
    sum_w[w] += 1
h_num_ix = {}
for i in range(H):
    num = sum_h[i]
    if num == 0:
        continue
    if not num in h_num_ix:
        h_num_ix[num] = set()
    h_num_ix[num].add(i)
w_num_ix = {}
for i in range(W):
    num = sum_w[i]
    if num == 0:
        continue
    if not num in w_num_ix:
        w_num_ix[num] = set()
    w_num_ix[num].add(i)
max_h_num = max(h_num_ix)
max_w_num = max(w_num_ix)
max_num = max_h_num + max_w_num - 1
for h_ix in h_num_ix[max_h_num]:
    for w_ix in w_num_ix[max_w_num]:
        if (h_ix, w_ix) in HW:
            continue
        print((max_num + 1))
        exit()
print(max_num)

-h, w, m = list(map(int, input().split())) -HW = set() -for _ in range(m): -    x, y = list(map(int, input().split())) -    HW.add((x - 1, y - 1)) -sum_h = [[0, 0] for _ in range(h)]  # [sum, index] -sum_w = [[0, 0] for _ in range(w)] +H, W, M = list(map(int, input().split())) +HW = set(tuple([int(x) - 1 for x in input().split()]) for _ in range(M)) +sum_h = [0] * H +sum_w = [0] * W -    sum_h[h][0] += 1 -    sum_w[w][0] += 1 -    sum_h[h][1] = h -    sum_w[w][1] = w +    sum_h[h] += 1 +    sum_w[w] += 1 -for num, ix in sum_h: +for i in range(H): +    num = sum_h[i] +    if num == 0: +        continue -    h_num_ix[num].add(ix) +    h_num_ix[num].add(i) -for num, ix in sum_w: +for i in range(W): +    num = sum_w[i] +    if num == 0: +        continue -    w_num_ix[num].add(ix) +    w_num_ix[num].add(i) -        num = max_h_num + max_w_num -        max_num += 1 -        print(max_num) +        print((max_num + 1))