CodeEff/ECCO huggingface dataset:
# Original solution
from bisect import bisect_left, bisect_right

def exists(ite, x):
	return bool(bisect_right(ite, x) - bisect_left(ite, x))

H, W, M = list(map(int,input().split()))
targets = [list([int(x) - 1 for x in input().split()]) for i in range(M)]

cnth = [0] * H
cntw = [0] * W
wlist = [[] for i in range(H)]

for i in range(M):
	hi, wi = targets[i]
	cnth[hi] += 1
	cntw[wi] += 1
	wlist[hi].append(wi)

maxhi = []
maxwi = []
maxh = max(cnth)
maxw = max(cntw)

for i in range(H):
	wlist[i].sort()
	if cnth[i] == maxh:
		maxhi.append(i)
for i in range(W):
	if cntw[i] == maxw:
		maxwi.append(i)

for i in range(len(maxhi)):
	for j in range(len(maxwi)):
		if not exists(wlist[maxhi[i]], maxwi[j]):
			print((maxh + maxw))
			exit()
print((maxh + maxw - 1))

# Optimized solution
from bisect import bisect_left, bisect_right

H, W, M = list(map(int,input().split()))
targets = [list([int(x) - 1 for x in input().split()]) for i in range(M)]

cnth = [0] * H
cntw = [0] * W
wlist = [[] for i in range(H)]

for i in range(M):
	hi, wi = targets[i]
	cnth[hi] += 1
	cntw[wi] += 1
	wlist[hi].append(wi)

maxhi = []
maxwi = []
maxh = max(cnth)
maxw = max(cntw)

for i in range(H):
	wlist[i].sort()
	if cnth[i] == maxh:
		maxhi.append(i)
for i in range(W):
	if cntw[i] == maxw:
		maxwi.append(i)

for i in range(len(maxhi)):
	for j in range(len(maxwi)):
		if bisect_right(wlist[maxhi[i]], maxwi[j]) - bisect_left(wlist[maxhi[i]], maxwi[j]) == 0:
			print((maxh + maxw))
			exit()
print((maxh + maxw - 1))
# Original solution
H, W, M = list(map(int, input().split()))
bombs = []
for i in range(H):
    bombs.append([False] * W)
rows = []
for i in range(H):
    rows.append([i, 0])
cols = []
for i in range(W):
    cols.append([i, 0])
for i in range(M):
    y, x = [x - 1 for x in list(map(int, input().split()))]
    bombs[y][x] = True
    rows[y][1] += 1
    cols[x][1] += 1


rows = sorted(rows, key=lambda x: x[1], reverse=True)
cols = sorted(cols, key=lambda x: x[1], reverse=True)
answer = 0
for row in rows:
    a = cols[0][1] + row[1] - (1 if bombs[row[0]][cols[0][0]] else 0)
    if a > answer:
        answer = a
for col in cols:
    a = rows[0][1] + col[1] - (1 if bombs[rows[0][0]][col[0]] else 0)
    if a > answer:
        answer = a
print(answer)

# Optimized solution
H, W, M = list(map(int, input().split()))
bombs = {}
rows = []
cols = []
for i in range(H):
    rows.append([i, 0])
for i in range(W):
    cols.append([i, 0])
for i in range(M):
    y, x = [x - 1 for x in list(map(int, input().split()))]
    bombs[(y,x)] = True
    rows[y][1] += 1
    cols[x][1] += 1


rows = sorted(rows, key=lambda x: x[1], reverse=True)
cols = sorted(cols, key=lambda x: x[1], reverse=True)
answer = 0
for row in rows:
    a = cols[0][1] + row[1] - (1 if (row[0], cols[0][0]) in bombs else 0)
    if a > answer:
        answer = a
for col in cols:
    a = rows[0][1] + col[1] - (1 if (rows[0][0], col[0]) in bombs else 0)
    if a > answer:
        answer = a
print(answer)
# Original solution
import sys
input = sys.stdin.readline

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

row = [0]*h
col = [0]*w
enemy = []

for i in range(m):
    hh, ww = [int(x)-1 for x in input().split()]
    row[hh] += 1
    col[ww] += 1
    enemy.append((hh,ww))

enemy = set(enemy)
rmax = max(row)
cmax = max(col)

rind = [i for i,v in enumerate(row) if v == rmax]
cind = [i for i,v in enumerate(col) if v == cmax]

ans = 0
for r in rind:
    for c in cind:
        if (r, c) in enemy:
            ans = max(ans, rmax+cmax-1)
        else:
            ans = max(ans, rmax+cmax)
print(ans)

# Optimized solution
import sys
input = sys.stdin.readline

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

row = [0]*h
col = [0]*w
enemy = []

for i in range(m):
    hh, ww = [int(x)-1 for x in input().split()]
    row[hh] += 1
    col[ww] += 1
    enemy.append((hh,ww))

enemy = set(enemy)
rmax = max(row)
cmax = max(col)

on_r = row.count(rmax)
on_c = col.count(cmax)

on = 0
for hh, ww in enemy:
    if row[hh] == rmax and col[ww] == cmax:
        on += 1
if on == on_r*on_c:
    print((rmax+cmax-1))
else:
    print((rmax+cmax))
# Original solution
H, W, M = list(map(int, input().split()))

h = [0] * (H + 1)
w = [0] * (W + 1)
boms = set()

for _ in range(M):
    x, y = list(map(int, input().split()))
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

h_max = max(h)
w_max = max(w)

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]


def solve(h_max, w_max, boms):
    minus = []
    for x in h_idx:
        for y in w_idx:
            if (x, y) in boms:
                minus.append(-1)
            else:
                minus.append(0)
    return h_max + w_max + max(minus)


print((solve(h_max, w_max, boms)))

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

h = [0] * H
w = [0] * W
boms = set()

for _ in range(M):
    x, y = list(map(int, input().split()))
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

h_max = max(h)
w_max = max(w)

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]

minus = -1
for x in h_idx:
    for y in w_idx:
        if not (x, y) in boms:
            minus = 0
            break

print((h_max + w_max + minus))
# Original solution
h, w, m = list(map(int, input().split()))
nh = [0 for i in range(h)]
nw = [0 for j in range(w)]
bomb = [[] for i in range(h)]
for i in range(m):
    inp = list(map(int, input().split()))
    nh[inp[0] - 1] += 1
    nw[inp[1] - 1] += 1
    bomb[inp[0]-1].append(inp[1]-1)
maxh = max(nh)
maxw = max(nw)
counth = 0
countw = 0
hlis = []
wlis = []
for j in range(h):
    if nh[j] == maxh:
        counth += 1
        hlis.append(j)
for i in range(w):
    if nw[i] == maxw:
        countw += 1
        wlis.append(i)
if counth * countw > m:
    print((maxh + maxw))
    exit()
else:
    for j in hlis:
        for i in wlis:
            flag = False
            if i in bomb[j]:
                flag = True
            if not flag:
                print((maxh + maxw))
                exit()
    else:
        print((maxh + maxw - 1))

# Optimized solution
h, w, m = list(map(int, input().split()))
nh = [0 for i in range(h)]
nw = [0 for j in range(w)]
bomb = [set() for i in range(h)]
for i in range(m):
    inp = list(map(int, input().split()))
    nh[inp[0] - 1] += 1
    nw[inp[1] - 1] += 1
    bomb[inp[0]-1].add(inp[1]-1)
maxh = max(nh)
maxw = max(nw)
counth = 0
countw = 0
hlis = []
wlis = []
for j in range(h):
    if nh[j] == maxh:
        counth += 1
        hlis.append(j)
for i in range(w):
    if nw[i] == maxw:
        countw += 1
        wlis.append(i)
if counth * countw > m:
    print((maxh + maxw))
    exit()
else:
    for j in hlis:
        for i in wlis:
            flag = False
            if i in bomb[j]:
                flag = True
            if not flag:
                print((maxh + maxw))
                exit()
    else:
        print((maxh + maxw - 1))
# Original solution
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math
import itertools


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    H, W, M = LI()

    HList = [0]*H
    WList = [0]*W
    graph = [[0 for _ in range(W)] for _ in range(H)]

    for m in range(M):
        h, w = LI()
        HList[h-1] += 1
        WList[w-1] += 1
        graph[h-1][w-1] += 1

    Hmax = max(HList)
    Wmax = max(WList)

    HIndex = [i for i, v in enumerate(HList) if v == Hmax]
    WIndex = [i for i, v in enumerate(WList) if v == Wmax]

    ans = Hmax + Wmax
    for h in HIndex:
        for w in WIndex:
            if graph[h][w] == 0:
                print(ans)
                return

    print((ans-1))


if __name__ == '__main__':
    main()


# Optimized solution
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math
import itertools


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    H, W, M = LI()

    HList = [0]*H
    WList = [0]*W
    graph = set()
    for m in range(M):
        h, w = LI()
        HList[h-1] += 1
        WList[w-1] += 1
        graph.add((h-1, w-1))

    Hmax = max(HList)
    Wmax = max(WList)

    HIndex = [i for i, v in enumerate(HList) if v == Hmax]
    WIndex = [i for i, v in enumerate(WList) if v == Wmax]

    ans = Hmax + Wmax
    for h in HIndex:
        for w in WIndex:
            if not (h, w) in graph:
                print(ans)
                return

    print((ans-1))


if __name__ == '__main__':
    main()
# Original solution
from collections import Counter
import sys

H,W,M,*hw = list(map(int,open(0).read().split()))

h = hw[::2]
w = hw[1::2]

hw_set = set((hi,wi) for hi,wi in zip(h,w))


raw_count = Counter(h)
col_count = Counter(w)

raw_max = raw_count.most_common()[0][1]
col_max = col_count.most_common()[0][1]

ans = 0
for hi, rcount in raw_count.most_common():
    if rcount<raw_max:break
    for wi, ccount in col_count.most_common():
        if ccount<col_max: break
        
        if (hi,wi) in hw_set:
            ans = raw_max + col_max - 1
        else:
            print((raw_max + col_max))
            sys.exit()

print(ans)


# Optimized solution
from collections import Counter
import sys

H,W,M,*hw = list(map(int,open(0).read().split()))

h = hw[::2]
w = hw[1::2]

hw_set = set((hi,wi) for hi,wi in zip(h,w))


raw_count = Counter(h).most_common()
col_count = Counter(w).most_common()


raw_max = raw_count[0][1]
col_max = col_count[0][1]

ans = 0
for hi, rcount in raw_count:
    if rcount<raw_max:break
    for wi, ccount in col_count:
        if ccount<col_max: break
        
        if (hi,wi) in hw_set:
            ans = raw_max + col_max - 1
        else:
            print((raw_max + col_max))
            sys.exit()

print(ans)
# Original solution
H, W, M = list(map(int, input().split()))

bomb = []
row = [0] * H
column = [0] * W

for i in range(M):
    h, w = list(map(int, input().split()))
    h -= 1
    w -= 1
    
    bomb.append([h, w])
    
    row[h] += 1
    column[w] += 1
    
row_max = max(row)
col_max = max(column)

r_check = []
c_check = []
for i in range(H):
    if row[i] == row_max:
        r_check.append(i)

for i in range(W):
    if column[i] == col_max:
        c_check.append(i)

num = len(r_check) * len(c_check)

ans = row_max + col_max - 1
flg = False
if M < num:
    ans = row_max + col_max
else:
    for r in r_check:
        if flg:
            break
        for c in c_check:
            if not [r, c] in bomb:
                ans = row_max + col_max
                flg = True
                break

print(ans)


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

bomb = set()
row = [0] * H
column = [0] * W

for i in range(M):
    h, w = list(map(int, input().split()))
    h -= 1
    w -= 1
    
    bomb.add((h, w))
    
    row[h] += 1
    column[w] += 1
    
row_max = max(row)
col_max = max(column)

r_check = []
c_check = []
for i in range(H):
    if row[i] == row_max:
        r_check.append(i)

for i in range(W):
    if column[i] == col_max:
        c_check.append(i)

num = len(r_check) * len(c_check)

ans = row_max + col_max - 1
flg = False
if M < num:
    ans += 1
else:
    for r in r_check:
        if flg:
            break
        for c in c_check:
            if not (r, c) in bomb:
                ans += 1
                flg = True
                break

print(ans)
# Original solution
import sys

input = sys.stdin.readline
H, W, M = list(map(int, input().split()))
h_count = [0]*H
w_count = [0]*W
HW = [tuple(map(int, input().split())) for _ in range(M)]
map = [[False]*W for _ in range(H)]
for h, w in HW:
    h_count[h-1] += 1
    w_count[w-1] += 1
    map[h-1][w-1] = True
h_max, w_max = 0, 0
hs, ws = [], []
for i in range(H):
    if h_max < h_count[i]:
        h_max = h_count[i]
        hs = [i]
    elif h_max == h_count[i]:
        hs.append(i)
for i in range(W):
    if w_max < w_count[i]:
        w_max = w_count[i]
        ws = [i]
    elif w_max == w_count[i]:
        ws.append(i)

cnt = len(hs)*len(ws)
for h in hs:
    for w in ws:
        if not map[h][w]:
            print((h_max+w_max))
            sys.exit()
print((h_max+w_max-1))


# Optimized solution
import sys

input = sys.stdin.readline
H, W, M = list(map(int, input().split()))
h_count = [0]*H
w_count = [0]*W
HW = [tuple(map(int, input().split())) for _ in range(M)]
for h, w in HW:
    h_count[h-1] += 1
    w_count[w-1] += 1
h_max, w_max = 0, 0
hs, ws = [], []
for i in range(H):
    if h_max < h_count[i]:
        h_max = h_count[i]
        hs = [i]
    elif h_max == h_count[i]:
        hs.append(i)
for i in range(W):
    if w_max < w_count[i]:
        w_max = w_count[i]
        ws = [i]
    elif w_max == w_count[i]:
        ws.append(i)

HW = set(HW)
for h in hs:
    for w in ws:
        if (h+1, w+1) not in HW:
            print((h_max+w_max))
            sys.exit()
print((h_max+w_max-1))
# Original solution
import itertools
H,W,M = list(map(int,input().split()))
lsx = [0] + [0]*H
lsy = [0] + [0]*W
lsxy = []
for i in range(M):
    x,y = list(map(int,input().split()))
    lsx[x] += 1
    lsy[y] += 1
    lsxy.append((x,y))
maxx = max(lsx)
maxy = max(lsy)
lsmaxx = [i for i, x in enumerate(lsx) if x == maxx]
lsmaxy = [i for i, x in enumerate(lsy) if x == maxy]
lsp = list(itertools.product(lsmaxx,lsmaxy))
ii = 0
for i in range(M):
    if lsxy[i] in lsp:
        ii += 1
if len(lsp)-ii == 0:
    factor = 1
else:
    factor = 0
print((maxx+maxy-factor))


# Optimized solution
import itertools
H,W,M = list(map(int,input().split()))
lsx = [0] + [0]*H
lsy = [0] + [0]*W
lsxy = []
for i in range(M):
    x,y = list(map(int,input().split()))
    lsx[x] += 1
    lsy[y] += 1
    lsxy.append((x,y))
maxx = max(lsx)
maxy = max(lsy)
lsmaxx = [i for i, x in enumerate(lsx) if x == maxx]
lsmaxy = [i for i, x in enumerate(lsy) if x == maxy]
lsp = list(itertools.product(lsmaxx,lsmaxy))
factor = 1
for i in lsp:
    if not i in lsxy:
        factor = 0
        break
print((maxx+maxy-factor))
# Original solution
H,W,M = list(map(int,input().split()))
lsx = [0] + [0]*H
lsy = [0] + [0]*W
lsxy = []
for i in range(M):
    x,y = list(map(int,input().split()))
    lsx[x] += 1
    lsy[y] += 1
    lsxy.append([x,y])
maxx = max(lsx)
maxy = max(lsy)
lsmaxx = [i for i, x in enumerate(lsx) if x == maxx]
lsmaxy = [i for i, x in enumerate(lsy) if x == maxy]
lenlen = len(lsmaxx)*len(lsmaxy)
factor = 1
for i in lsmaxx:
    for j in lsmaxy:
        if not [i,j] in lsxy:
            factor = 0
            break
    if factor == 0:
        break
print((maxx+maxy-factor))


# Optimized solution
H,W,M = list(map(int,input().split()))
lsx = [0] + [0]*H
lsy = [0] + [0]*W
lsxy = []
for i in range(M):
    x,y = list(map(int,input().split()))
    lsx[x] += 1
    lsy[y] += 1
    lsxy.append([x,y])
maxx = max(lsx)
maxy = max(lsy)
cx = lsx.count(maxx)
cy = lsy.count(maxy)
al = cx*cy
for i in range(M):
    if lsx[lsxy[i][0]] == maxx and lsy[lsxy[i][1]] == maxy:
        al -= 1
if al == 0:
    factor = 1
else:
    factor = 0        
print((maxx+maxy-factor))
# Original solution
from itertools import product
H,W,M = list(map(int,input().split()))
h_list = [0] * M
w_list = [0] * M
for m in range(M):
    h_list[m],w_list[m] = list(map(int,input().split()))
hh_list = [0] * H
ww_list = [0] * W
for m in range(M):
    hh_list[h_list[m]-1] += 1
for m in range(M):
    ww_list[w_list[m]-1] += 1
h_max = max(hh_list)
w_max = max(ww_list)

h_ans = []
w_ans = []

for hh in range(H):
    if hh_list[hh] == h_max:
        h_ans.append(hh)
for ww in range(W):
    if ww_list[ww] == w_max:
        w_ans.append(ww)
cnt = 0
for i,j in zip(h_list,w_list):
    if i-1 in set(h_ans) and j-1 in set(w_ans):
        cnt += 1
if cnt == len(h_ans) * len(w_ans):
    print((h_max + w_max - 1))
else:
    print((h_max + w_max))

# Optimized solution
from itertools import product
H,W,M = list(map(int,input().split()))
h_list = [0] * M
w_list = [0] * M
for m in range(M):
    h_list[m],w_list[m] = list(map(int,input().split()))
hh_list = [0] * H
ww_list = [0] * W
for m in range(M):
    hh_list[h_list[m]-1] += 1
for m in range(M):
    ww_list[w_list[m]-1] += 1
h_max = max(hh_list)
w_max = max(ww_list)

h_ans = []
w_ans = []

for hh in range(H):
    if hh_list[hh] == h_max:
        h_ans.append(hh)
for ww in range(W):
    if ww_list[ww] == w_max:
        w_ans.append(ww)
cnt = 0
h_set = set(h_ans)
w_set = set(w_ans)
for i,j in zip(h_list,w_list):
    if i-1 in h_set and j-1 in w_set:
        cnt += 1
if cnt == len(h_ans) * len(w_ans):
    print((h_max + w_max - 1))
else:
    print((h_max + w_max))
# Original solution
from collections import defaultdict


def solve(H, M, W, bombs):
    count_h = defaultdict(int)
    count_w = defaultdict(int)
    for b in bombs:
        h = str(b[0])
        count_h[h] += 1
        w = str(b[1])
        count_w[w] += 1
    max_h = max(count_h.values())
    max_w = max(count_w.values())
    points_h = [int(k) for k in list(count_h.keys()) if count_h[k] == max_h]
    points_w = [int(k) for k in list(count_w.keys()) if count_w[k] == max_w]
    ans = max_h + max_w
    if _find_cross_bomb(points_h, points_w, bombs):
        ans -= 1
    print(ans)


def _find_cross_bomb(points_h, points_w, bombs):
    c = 0
    for b in bombs:
        if (b[0]) in points_h:
            if (b[1]) in points_w:
                c += 1
    return c == len(points_h) * len(points_w)


if __name__ == "__main__":
    H, W, M = list(map(int, input().split()))
    bombs = [list([int(x) - 1 for x in input().split()]) for i in range(M)]
    solve(H, M, W, bombs)


# Optimized solution
import sys


def solve():
    readline = sys.stdin.readline
    H, W, M = list(map(int, readline().split()))
    h = [0] * H
    w = [0] * W
    b = set()
    for _ in range(M):
        y, x = list(map(int, readline().split()))
        x -= 1
        y -= 1
        h[y] += 1
        w[x] += 1
        b.add(y * W + x)
    h = sorted(zip(h, list(range(H))), reverse=True)
    ans = 0
    for i in range(W):
        x = w[i]
        for y, j in h:
            if x + y > ans:
                if j * W + i in b:
                    ans = x + y - 1
                else:
                    ans = x + y
                    break
            else:
                break
    print(ans)


if __name__ == '__main__':
    solve()
# Original solution
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
# MOD = 10 ** 9 + 7
MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list([int(x) - 1 for x in sys.stdin.readline().rstrip().split()])


# ===CODE===

def main():
    h, w, m = ns()

    hm = [0 for _ in range(h)]
    wm = [0 for _ in range(w)]

    m_pos = {}

    for _ in range(m):
        hi, wi = ns()
        hi, wi = hi - 1, wi - 1
        hm[hi] += 1
        wm[wi] += 1

        if hi in list(m_pos.keys()):
            m_pos[hi].add(wi)
        else:
            m_pos[hi] = {wi}

    h_max = []
    w_max = []

    tmax = -1
    for i, hi in enumerate(hm):
        if hi > tmax:
            tmax = hi
            h_max = [i]
        elif hi == tmax:
            h_max.append(i)

    tmax = -1
    for i, wi in enumerate(wm):
        if wi > tmax:
            tmax = wi
            w_max = [i]
        elif wi == tmax:
            w_max.append(i)

    ans = 0

    for hi in h_max:
        for wi in w_max:
            if wi in m_pos[hi]:
                ans = max(ans, hm[hi] + wm[wi] - 1)

            else:
                ans = max(ans, hm[hi] + wm[wi])

    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
# MOD = 10 ** 9 + 7
MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list([int(x) - 1 for x in sys.stdin.readline().rstrip().split()])


# ===CODE===

def main():
    h, w, m = ns()

    hm = [0 for _ in range(h)]
    wm = [0 for _ in range(w)]

    m_pos = {}

    for _ in range(m):
        hi, wi = ns()
        hi, wi = hi - 1, wi - 1
        hm[hi] += 1
        wm[wi] += 1

        if hi in list(m_pos.keys()):
            m_pos[hi].add(wi)
        else:
            m_pos[hi] = {wi}

    h_max = []
    w_max = []

    tmax = -1
    for i, hi in enumerate(hm):
        if hi > tmax:
            tmax = hi
            h_max = [i]
        elif hi == tmax:
            h_max.append(i)

    tmax = -1
    for i, wi in enumerate(wm):
        if wi > tmax:
            tmax = wi
            w_max = [i]
        elif wi == tmax:
            w_max.append(i)

    ans = 0
    breakflg = False

    for hi in h_max:
        for wi in w_max:
            if wi in m_pos[hi]:
                ans = max(ans, hm[hi] + wm[wi] - 1)
            else:
                ans = max(ans, hm[hi] + wm[wi])
                breakflg = True
                break
        if breakflg:
            break

    print(ans)


if __name__ == '__main__':
    main()
# Original solution
H, W, M = list(map(int, input().split()))
bomb = [list(map(int, input().split())) for i in range(M)]

column_cnt = [0]*W
row_cnt = [0]*H

for i in range(M):
    row_cnt[bomb[i][0]-1] += 1
    column_cnt[bomb[i][1]-1] += 1

row_max_index = row_cnt.index(max(row_cnt))
column_max_index = column_cnt.index(max(column_cnt))

bomb_cnt_max = 0

for i in range(M):
    bomb_cnt = row_cnt[bomb[i][0]-1] + column_cnt[column_max_index]
    if [bomb[i][0], column_max_index+1] in bomb:
        bomb_cnt -= 1
    bomb_cnt_max = max(bomb_cnt_max, bomb_cnt)

    bomb_cnt = column_cnt[bomb[i][1]-1] + row_cnt[row_max_index]
    if [row_max_index+1, bomb[i][1]] in bomb:
        bomb_cnt -= 1
    bomb_cnt_max = max(bomb_cnt_max, bomb_cnt)

print(bomb_cnt_max)

# Optimized solution
H, W, M = list(map(int, input().split()))
bomb = set([tuple(map(int, input().split())) for i in range(M)])

column_cnt = [0]*W
row_cnt = [0]*H

for bomb_pos in bomb:
    row_cnt[bomb_pos[0]-1] += 1
    column_cnt[bomb_pos[1]-1] += 1

row_max_index = row_cnt.index(max(row_cnt))
column_max_index = column_cnt.index(max(column_cnt))

bomb_cnt_max = 0

for bomb_pos in bomb:
    bomb_cnt = row_cnt[bomb_pos[0]-1] + column_cnt[column_max_index]
    if (bomb_pos[0], column_max_index+1) in bomb:
        bomb_cnt -= 1
    bomb_cnt_max = max(bomb_cnt_max, bomb_cnt)

    bomb_cnt = column_cnt[bomb_pos[1]-1] + row_cnt[row_max_index]
    if (row_max_index+1, bomb_pos[1]) in bomb:
        bomb_cnt -= 1
    bomb_cnt_max = max(bomb_cnt_max, bomb_cnt)

print(bomb_cnt_max)