import heapq
H, W, M = map(int, input().split())
bomb = []
for i in range(M):
    h, w = map(int, input().split())
    h-=1; w-=1
    bomb.append((h, w))

row = [0] * H
col = [0] * W

for h, w in bomb:
    row[h] += 1
    col[w] += 1

lmax = max(row) + max(col)
row = [(r, i) for i, r in enumerate(row)]
col = [(c, i) for i, c in enumerate(col)]
row.sort(reverse=True)
col.sort(reverse=True)
bomb = set(bomb)

for r, i in row:
    for c, j in col:
        if r+c < lmax: break
        if not (i, j) in bomb:
            print(lmax)
            exit()
print(lmax-1) import heapq heapq H, W, M = map(int, input().split()) H map(int, input().split()) map int input().split() ().split () input split W M bomb = [] bomb [] for i in range(M):
    h, w = map(int, input().split())
    h-=1; w-=1
    bomb.append((h, w)) i range(M) range M h, w = map(int, input().split()) h map(int, input().split()) map int input().split() ().split () input split w h-=1 h 1 w-=1 w 1 bomb.append((h, w)) bomb.append bomb append (h, w) h w row = [0] * H row [0] * H [0] 0 H col = [0] * W col [0] * W [0] 0 W for h, w in bomb:
    row[h] += 1
    col[w] += 1 h w bomb row[h] += 1 row[h] row h 1 col[w] += 1 col[w] col w 1 lmax = max(row) + max(col) lmax max(row) + max(col) max(row) max row max(col) max col (r, i) for i, r in enumerate(row) for i, r in enumerate(row) i r enumerate(row) enumerate row for i, r in enumerate(row) (r, i) r i row = [(r, i) for i, r in enumerate(row)] row [(r, i) for i, r in enumerate(row)] (c, i) for i, c in enumerate(col) for i, c in enumerate(col) i c enumerate(col) enumerate col for i, c in enumerate(col) (c, i) c i col = [(c, i) for i, c in enumerate(col)] col [(c, i) for i, c in enumerate(col)] row.sort(reverse=True) row.sort row sort reverse=True reverse True col.sort(reverse=True) col.sort col sort reverse=True reverse True bomb = set(bomb) bomb set(bomb) set bomb for r, i in row:
    for c, j in col:
        if r+c < lmax: break
        if not (i, j) in bomb:
            print(lmax)
            exit() r i row for c, j in col:
        if r+c < lmax: break
        if not (i, j) in bomb:
            print(lmax)
            exit() c j col if r+c < lmax: break
         r+c < lmax r+c r c lmax if not (i, j) in bomb:
            print(lmax)
            exit() not (i, j) in bomb (i, j) in bomb (i, j) i j bomb print(lmax) print lmax exit() exit print(lmax-1) print lmax-1 lmax 1 w-=1 1 w M = map(int, input().split()) map(int, input().split()) M lmax = max(row) + max(col) max(row) + max(col) lmax bomb = set(bomb) set(bomb) bomb col = [0] * W [0] * W col row = [(r, i) for i, r in enumerate(row)] [(r, i) for i, r in enumerate(row)] row w = map(int, input().split()) map(int, input().split()) w bomb = [] [] bomb h-=1 1 h H, W, M = map(int, input().split()) map(int, input().split()) H col = [(c, i) for i, c in enumerate(col)] [(c, i) for i, c in enumerate(col)] col W, M = map(int, input().split()) map(int, input().split()) W h, w = map(int, input().split()) map(int, input().split()) h row = [0] * H [0] * H row
import heapq
H, W, M = map(int, input().split())
bomb = []
for i in range(M):
    h, w = map(int, input().split())
    h-=1; w-=1
    bomb.append((h, w))

row = [0] * H
col = [0] * W

for h, w in bomb:
    row[h] += 1
    col[w] += 1

lmax = max(row) + max(col)
row = [(r, i) for i, r in enumerate(row)]
col = [(c, i) for i, c in enumerate(col)]
row.sort(reverse=True)
col.sort(reverse=True)
bomb = set(bomb)

for r, i in row:
    for c, j in col:
        if r+c < lmax: break
        if not (i, j) in bomb:
            print(lmax)
            exit()
print(lmax-1)
