import itertools
H, W, M = map(int, input().split())
Bh = [0]*(H+1)
Bw = [0]*(W+1)
OD = set()

for _ in range(M):
    h, w = map(int, input().split())
    Bh[h] += 1
    Bw[w] += 1
    OD.add((h, w))

M1 = max(Bh)
M2 = max(Bw)
l1 = [i for i, x in enumerate(Bh) if x == M1]
l2 = [j for j, x in enumerate(Bw) if x == M2]
for i, j in itertools.product(l1, l2):
    if (i, j) not in OD:
        break
else:
    print(M1+M2-1)
    exit()
print(M1+M2) import itertools itertools H, W, M = map(int, input().split()) H map(int, input().split()) map int input().split() ().split () input split W M Bh = [0]*(H+1) Bh [0]*(H+1) [0] 0 H+1 H 1 Bw = [0]*(W+1) Bw [0]*(W+1) [0] 0 W+1 W 1 OD = set() OD set() set for _ in range(M):
    h, w = map(int, input().split())
    Bh[h] += 1
    Bw[w] += 1
    OD.add((h, w)) _ range(M) range M h, w = map(int, input().split()) h map(int, input().split()) map int input().split() ().split () input split w Bh[h] += 1 Bh[h] Bh h 1 Bw[w] += 1 Bw[w] Bw w 1 OD.add((h, w)) OD.add OD add (h, w) h w M1 = max(Bh) M1 max(Bh) max Bh M2 = max(Bw) M2 max(Bw) max Bw i for i, x in enumerate(Bh) if x == M1 for i, x in enumerate(Bh) if x == M1 i x enumerate(Bh) enumerate Bh x == M1 x M1 if x == M1 i l1 = [i for i, x in enumerate(Bh) if x == M1] l1 [i for i, x in enumerate(Bh) if x == M1] j for j, x in enumerate(Bw) if x == M2 for j, x in enumerate(Bw) if x == M2 j x enumerate(Bw) enumerate Bw x == M2 x M2 if x == M2 j l2 = [j for j, x in enumerate(Bw) if x == M2] l2 [j for j, x in enumerate(Bw) if x == M2] for i, j in itertools.product(l1, l2):
    if (i, j) not in OD:
        break
else:
    print(M1+M2-1)
    exit() i j itertools.product(l1, l2) itertools.product itertools product l1 l2 if (i, j) not in OD:
        break (i, j) not in OD (i, j) i j OD break print(M1+M2-1) print M1+M2-1 M1+M2 M1 M2 1 exit() exit print(M1+M2) print M1+M2 M1 M2 H, W, M = map(int, input().split()) map(int, input().split()) H W, M = map(int, input().split()) map(int, input().split()) W Bh = [0]*(H+1) [0]*(H+1) Bh M = map(int, input().split()) map(int, input().split()) M w = map(int, input().split()) map(int, input().split()) w OD = set() set() OD l1 = [i for i, x in enumerate(Bh) if x == M1] [i for i, x in enumerate(Bh) if x == M1] l1 M2 = max(Bw) max(Bw) M2 M1 = max(Bh) max(Bh) M1 Bw = [0]*(W+1) [0]*(W+1) Bw h, w = map(int, input().split()) map(int, input().split()) h l2 = [j for j, x in enumerate(Bw) if x == M2] [j for j, x in enumerate(Bw) if x == M2] l2
import itertools
H, W, M = map(int, input().split())
Bh = [0]*(H+1)
Bw = [0]*(W+1)
OD = set()

for _ in range(M):
    h, w = map(int, input().split())
    Bh[h] += 1
    Bw[w] += 1
    OD.add((h, w))

M1 = max(Bh)
M2 = max(Bw)
l1 = [i for i, x in enumerate(Bh) if x == M1]
l2 = [j for j, x in enumerate(Bw) if x == M2]
for i, j in itertools.product(l1, l2):
    if (i, j) not in OD:
        break
else:
    print(M1+M2-1)
    exit()
print(M1+M2)
