CodeEff/ECCO huggingface dataset:
# Original solution
# 初期入力
import sys
from collections import defaultdict
input = sys.stdin.readline  #文字列では使わない
H,W,M = list(map(int, input().split()))

bom_H ={i:0 for i in range(1,H+1)}
bom_W ={i:0 for i in range(1,W+1)}
posision =defaultdict(int)
for i in range(M):
    h,w = list(map(int, input().split()))
    bom_H[h] +=1
    bom_W[w] +=1
    posision[(h,w)] =1
max_H = [kv for kv in list(bom_H.items()) if kv[1] == max(bom_H.values())]
max_W = [kv for kv in list(bom_W.items()) if kv[1] == max(bom_W.values())]


ans =0
for p_h,v_h in max_H:
    for p_w,v_w in max_W:
        if posision[(p_h,p_w)] ==1:
            ans =max(ans,v_h +v_w -1)
        else:
            ans =max(ans,v_h +v_w )
            break
print(ans)

# Optimized solution
import sys


H, W, M = list(map(int, input().split()))
bomb = [tuple([int(x) - 1 for x in s.split()]) for s in sys.stdin.readlines()]
X = [0] * H  # X:各行の爆破対象の個数
Y = [0] * W  # Y:各列の爆破対象の個数
for h, w in bomb:
    X[h] += 1
    Y[w] += 1
maxX = max(X)
maxY = max(Y)

R = [h for h, x in enumerate(X) if x == maxX]  # R:爆破対象の数が最大となる行の番号
C = [w for w, y in enumerate(Y) if y == maxY]  # C:爆破対象の数が最大となる列の番号

bomb = set(bomb)
for r in R:
    for c in C:
        # (r, c)に爆破対象が存在しないとき, maxX + maxY が答えとなることが確定するため, 
        # 即座に探索を終了する.
        if (r, c) not in bomb:
            print((maxX + maxY))
            exit()
print((maxX + maxY - 1))
# Original solution
# 初期入力
import sys
from collections import defaultdict
input = sys.stdin.readline  #文字列では使わない
H,W,M = list(map(int, input().split()))

bom_H =defaultdict(int)
bom_W =defaultdict(int)
posision =set()
for i in range(M):
    h,w = list(map(int, input().split()))
    bom_H[h] +=1
    bom_W[w] +=1
    posision.add((h,w))
indx_H = [k for k,v in list(bom_H.items()) if v == max(bom_H.values())]
indx_W = [k for k,v in list(bom_W.items()) if v == max(bom_W.values())]
set_max_H = set(indx_H)
set_max_W = set(indx_W)
temp_H =max(bom_H.values())
temp_W =max(bom_W.values())

flag =False
for h in set_max_H:
    for w in set_max_W:
        if (h,w) not in posision:
            flag =True
            break
    if flag==True:
        break

if flag ==True:
    print((temp_H +temp_W ))
else:
    print((temp_H +temp_W -1))

# Optimized solution
# 初期入力
import sys
from collections import defaultdict
input = sys.stdin.readline  #文字列では使わない
H,W,M = list(map(int, input().split()))

bom_H =defaultdict(int)
bom_W =defaultdict(int)
posision =set()
for i in range(M):
    h,w = list(map(int, input().split()))
    bom_H[h] +=1
    bom_W[w] +=1
    posision.add((h,w))
temp_H =max(bom_H.values())
temp_W =max(bom_W.values())
indx_H = [k for k,v in list(bom_H.items()) if v == temp_H]
indx_W = [k for k,v in list(bom_W.items()) if v == temp_W]
set_max_H = set(indx_H)
set_max_W = set(indx_W)


flag =False
for h in set_max_H:
    for w in set_max_W:
        if (h,w) not in posision:
            flag =True
            break
    if flag==True:
        break

if flag ==True:
    print((temp_H +temp_W ))
else:
    print((temp_H +temp_W -1))
# Original solution
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

H,W,M = MI()
hw = [tuple(MI()) for _ in range(M)]
A = [0]*(H+1)
B = [0]*(W+1)

from collections import defaultdict
d = defaultdict(int)
for h,w in hw:
    A[h] += 1
    B[w] += 1
    d[(h,w)] = 1


ma = max(A)
mb = max(B)
ans = ma+mb
C,D = [],[]
for i in range(1,H+1):
    if A[i] == ma:
        C.append(i)
for i in range(1,W+1):
    if B[i] == mb:
        D.append(i)

if len(C)*len(D) > M:
    print(ans)
else:
    for i in C:
        for j in D:
            if d[(i,j)] == 0:
                print(ans)
                exit()
    print((ans-1))


# Optimized solution
import sys
def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))

H,W,M = MI()

X = [0]*(H+1)  # X[i] = x座標がiである爆破対象はいくつあるか
Y = [0]*(W+1)  # Y[i] = y座標がiである爆破対象はいくつあるか

from collections import defaultdict
d = defaultdict(int)  # d[(h,w)] == 1 ⇔ 座標(h,w)に爆破対象が存在する

for i in range(M):
    h,w = MI()
    X[h] += 1
    Y[w] += 1
    d[(h,w)] = 1

mx = max(X)
my = max(Y)
ans = mx+my
A = [i for i in range(1,H+1) if X[i] == mx]
B = [i for i in range(1,W+1) if Y[i] == my]

if len(A)*len(B) > M:
    print(ans)
else:
    for i in A:
        for j in B:
            if d[(i,j)] == 0:
                print(ans)
                exit()
    print((ans-1))
# Original solution
import collections
import sys

*data, = list(map(int, sys.stdin.read().split()[::-1]))

def inp():
    return data.pop()

h, w, m = inp(), inp(), inp()


targets = set()
xs = []
ys = []
for _ in range(m):
    y, x = inp(), inp()
    # y -= 1
    # x -= 1
    ys.append(y)
    xs.append(x)
    targets.add((y, x))

x_stat = collections.Counter(xs)
y_stat = collections.Counter(ys)

xs = sorted(set(xs), key=lambda obj: x_stat[obj], reverse=True)
ys = sorted(set(ys), key=lambda obj: y_stat[obj], reverse=True)

mx_x = x_stat[xs[0]]
mx_y = y_stat[ys[0]]
while xs and x_stat[xs[-1]] < x_stat[xs[0]]:
    xs.pop()
while ys and y_stat[ys[-1]] < y_stat[ys[0]]:
    ys.pop()
best_res = 0
# print(xs, x_stat)
# print(ys, y_stat)
for x in xs:
    for y in ys:
        cur = x_stat[x] + y_stat[y] - ((y, x) in targets)
        best_res = max(cur, best_res)
print(best_res)





# Optimized solution
import collections
import sys

*data, = list(map(int, sys.stdin.read().split()[::-1]))

def inp():
    return data.pop()

h, w, m = inp(), inp(), inp()


targets = set()
xs = []
ys = []
for _ in range(m):
    y, x = inp(), inp()
    # y -= 1
    # x -= 1
    ys.append(y)
    xs.append(x)
    targets.add((y, x))

x_stat = collections.Counter(xs)
y_stat = collections.Counter(ys)

xs = sorted(set(xs), key=lambda obj: x_stat[obj], reverse=True)
ys = sorted(set(ys), key=lambda obj: y_stat[obj], reverse=True)

mx_x = x_stat[xs[0]]
mx_y = y_stat[ys[0]]
while xs and x_stat[xs[-1]] < x_stat[xs[0]]:
    xs.pop()
while ys and y_stat[ys[-1]] < y_stat[ys[0]]:
    ys.pop()
# print(xs, x_stat)
# print(ys, y_stat)

found = False
for x in xs:
    for y in ys:
        if (y, x) not in targets:
            found = True
            break
ans = mx_y + mx_x
if not found:
    ans -= 1
print(ans)
# Original solution
h, w, m = list(map(int, input().split()))

bomb = [[False for i in range(w)] for j in range(h)]
cnth = [0 for i in range(h)]
cntw = [0 for i in range(w)]
for i in range(m):
  x, y = list(map(int, input().split()))
  x -= 1
  y -= 1
  cnth[x] += 1
  cntw[y] += 1
  bomb[x][y] = True
maxh = max(cnth)
maxw = max(cntw)

xx = []
yy = []
for i in range(h):
  if maxh == cnth[i]:
    xx.append(i)
for i in range(w):
  if maxw == cntw[i]:
    yy.append(i)


ans = maxh + maxw -1
for i in xx:
  for j in yy:
    if not bomb[i][j]:
      ans += 1
      print (ans)
      exit()
print (ans)


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

bomb = []
cnth = [0 for i in range(h)]
cntw = [0 for i in range(w)]
bomh = [set() for i in range(h)]
bomw = [set() for i in range(w)]
for i in range(m):
  x, y = list(map(int, input().split()))
  x -= 1
  y -= 1
  cnth[x] += 1
  cntw[y] += 1
  bomh[x].add(y)
  bomw[y].add(x)
  bomb.append([x,y])
maxh = max(cnth)
maxw = max(cntw)
ans = maxh + maxw - 1

xx = []
yy = []
for i in range(h):
  if maxh == cnth[i]:
    xx.append(i)
for i in range(w):
  if maxw == cntw[i]:
    yy.append(i)

for i in xx:
  for j in yy:
    if j not in bomh[i]:
      print((ans+1))
      exit()
print (ans)
# Original solution
H,W,M=list(map(int,input().split()))
s=[list(map(int,input().split())) for _ in range(M)]
Tr=[0 for _ in range(H+1)]
Tc=[0 for _ in range(W+1)]
for i in range(M):
    Tr[s[i][0]]+=1
    Tc[s[i][1]]+=1
mr=max(Tr)
mc=max(Tc)
Mr=[i for i,x in enumerate(Tr) if x==mr]
Mc=[i for i,x in enumerate(Tc) if x==mc]

ans=0
for i in range(len(Mr)):
    for j in range(len(Mc)):
        if not ([Mr[i],Mc[j]] in s):
            ans=mr+mc
            break
    else:
        continue
    break
if ans==0:
    ans=mr+mc-1
print(ans)

# Optimized solution
H,W,M=list(map(int,input().split()))
s=[list(map(int,input().split())) for _ in range(M)]
Tr=[0 for _ in range(H+1)]
Tc=[0 for _ in range(W+1)]
for i in range(M):
    Tr[s[i][0]]+=1
    Tc[s[i][1]]+=1
mr=max(Tr)
mc=max(Tc)
Mr=[0 for _ in range(H+1)]
Mc=[0 for _ in range(W+1)]
Nmr=0
Nmc=0
for i in range(len(Tr)):
    if Tr[i]==mr:
        Mr[i]=1
        Nmr+=1
for i in range(len(Tc)):
    if Tc[i]==mc:
        Mc[i]=1
        Nmc+=1
cnt=0
for i in range(M):
    if Mr[s[i][0]]==1 and Mc[s[i][1]]==1:
        cnt+=1
if cnt<Nmr*Nmc:
    print((mr+mc))
else:
    print((mr+mc-1))
# Original solution
from collections import*
h,w,m=list(map(int,input().split()))
d=defaultdict(int)
a=[0]*h
b=[0]*w
for _ in range(m):
  x,y=list(map(int,input().split()))
  x-=1
  y-=1
  a[x]+=1
  b[y]+=1
  d[x*10**6+y]+=1

ma=max(a)
mb=max(b)

ind_x=[i for i,j in enumerate(a) if j==ma]
ind_y=[i for i,j in enumerate(b) if j==mb]


for x in ind_x:
  for y in ind_y:
    if d[x*10**6+y]==0:
      print((ma+mb))
      exit()
print((ma+mb-1))


# Optimized solution
h,w,m=list(map(int,input().split()))
d=dict()
a=[0]*h
b=[0]*w
for _ in range(m):
  x,y=list(map(int,input().split()))
  x-=1
  y-=1
  a[x]+=1
  b[y]+=1
  d[x*10**6+y]=1

ma=max(a)
mb=max(b)

ind_x=[i for i,j in enumerate(a) if j==ma]
ind_y=[i for i,j in enumerate(b) if j==mb]


for x in ind_x:
  for y in ind_y:
    if not(x*10**6+y in d):
      print((ma+mb))
      exit()
print((ma+mb-1))
# Original solution
h,w,m=list(map(int,input().split()))
d=dict()
s=set()
a=[0]*h
b=[0]*w
for _ in range(m):
  x,y=list(map(int,input().split()))
  x-=1
  y-=1
  a[x]+=1
  b[y]+=1
  d[x*10**6+y]=1
  s.add(x*10**6+y)

ma=max(a)
mb=max(b)

ind_x=[i for i,j in enumerate(a) if j==ma]
ind_y=[i for i,j in enumerate(b) if j==mb]


for x in ind_x:
  for y in ind_y:
    if not(x*10**6+y in s):
      print((ma+mb))
      exit()
print((ma+mb-1))


# Optimized solution
h,w,m=list(map(int,input().split()))
a=[0]*h;b=[0]*w
s=set()
for _ in range(m):
  x,y=[int(x)-1 for x in input().split()]
  a[x]+=1;b[y]+=1
  s.add(x*10**6+y)
ma=max(a);mb=max(b)
c=[i for i,v in enumerate(a) if v==ma]
d=[i for i,v in enumerate(b) if v==mb]
for x in c:
  for y in d:
    if not(x*10**6+y in s):
      print((ma+mb))
      exit()
print((ma+mb-1))
# Original solution
f=lambda:map(int,input().split())
H,W,M=f()
g=[set() for _ in range(H)]
ch=[0]*H
cw=[0]*W
for _ in range(M):
  h,w=f()
  g[h-1].add(w-1)
  ch[h-1]+=1
  cw[w-1]+=1
mh=max(ch)
mw=max(cw)
lh=[i for i in range(H) if ch[i]==mh]
lw=[i for i in range(W) if cw[i]==mw]
c=mh+mw
for i in lh:
  if len(g[i])<1: exit(print(c))
  for j in lw:
    if j not in g[i]: exit(print(c))
print(c-1)


# Optimized solution
f=lambda:list(map(int,input().split()))
h,w,m=f()
l,H,W=[],[0]*-~h,[0]*-~w
for _ in range(m):
  x,y=f()
  l+=[(x,y)]
  H[x]+=1
  W[y]+=1
s,t=max(H),max(W)
print((s+t-(H.count(s)*W.count(t)==sum(H[x]+W[y]==s+t for x,y in l))))
# Original solution
import sys
from collections import deque
H, W, M = list(map(int, input().split()))
S = list(tuple(map(int, input().split())) for _ in range(M))
hh = dict()
ww = dict()
for i in range(M):
    h, w = S[i]
    if h in list(hh.keys()):
        hh[h] += 1
    else:
        hh[h] = 1
    if w in list(ww.keys()):
        ww[w] += 1
    else:
        ww[w] = 1
hhh = sorted(list(hh.items()), key=lambda x:x[1], reverse=True)
www = sorted(list(ww.items()), key=lambda x:x[1], reverse=True)
ans = hhh[0][1] + www[0][1]
if (hhh[0][0], www[0][0]) not in S:
    print(ans)
    sys.exit()
h = hhh[0][0]
for j in range(1, len(www)):
        if www[j][1] == www[j-1][1]:
            if (h, www[j][0]) not in S:
                print(ans)
                sys.exit()
        else:
            break
for i in range(1, len(hhh)):
    if hhh[i][1] == hhh[i-1][1]:
        h = hhh[i][0]
        if (h, www[0][0]) not in S:
            print(ans)
            sys.exit()
        for j in range(1, len(www)):
            if www[j][1] == www[j-1][1]:
                if (h, www[j][0]) not in S:
                    print(ans)
                    sys.exit()
            else:
                break
    else:
        break
print((ans-1))
        


# Optimized solution
import sys
from collections import deque
H, W, M = list(map(int, input().split()))
S = list(tuple(map(int, input().split())) for _ in range(M))
hh = dict()
ww = dict()
for i in range(M):
    h, w = S[i]
    if h in list(hh.keys()):
        hh[h] += 1
    else:
        hh[h] = 1
    if w in list(ww.keys()):
        ww[w] += 1
    else:
        ww[w] = 1
hhh = sorted(list(hh.items()), key=lambda x:x[1], reverse=True)
www = sorted(list(ww.items()), key=lambda x:x[1], reverse=True)
h = hhh[0][1]
w = www[0][1]
ans = h+w
Nh = 0
Nw = 0
for i in range(len(hhh)):
    if h == hhh[i][1]:
        Nh += 1
    else:
        break
for i in range(len(www)):
    if w == www[i][1]:
        Nw += 1
    else:
        break
tt = Nh*Nw
if tt > M:
    print(ans)
    sys.exit()

for tmp in S:
    if hh[tmp[0]] == h and ww[tmp[1]] == w:
        tt -= 1
if tt > 0:
    print(ans)
else:
    print((ans-1))
# Original solution
h, w, m = list(map(int, input().split()))
h_l = [[] for i in range(h + 1)]
w_l = [[] for i in range(w + 1)]
max_h = 0
max_h_l = []
max_w = 0
max_w_l = []
inputs = []
for _ in range(m):
    h, w = list(map(int, input().split()))
    inputs.append([h,w])
    if h_l[h] :
        h_l[h][1].append(w)
        h_l[h][0] += 1
    else:
        h_l[h] = [1, [w]]
        
    if h_l[h][0] > max_h:
        max_h_l = [h]
        max_h = h_l[h][0]
    elif h_l[h][0] == max_h:
        max_h_l.append(h)
 
        
    if w_l[w]:
        w_l[w][1].append(h)
        w_l[w][0] += 1
    else:
        w_l[w] = [1, [h]]
    if w_l[w][0] > max_w:
        max_w_l = [w]
        max_w = w_l[w][0]
    elif w_l[w][0] == max_w:
        max_w_l.append(w)
 
flag = 0
ans = 0
for i in max_h_l:
    if flag == 1:
        break
    for j in max_w_l:
        if flag == 1:
            break
        if j in h_l[i][1]:
            ans = max_h + max_w - 1
        else:
            ans = max_h + max_w
            flag = 1
print(ans)

# Optimized solution
h, w, m = list(map(int, input().split()))
h_l = [[] for i in range(h + 1)]
w_l = [[] for i in range(w + 1)]
max_h = 0
max_h_l = []
max_w = 0
max_w_l = []
inputs = {}
for _ in range(m):
    h, w = list(map(int, input().split()))
    inputs.setdefault(h, set([w]))
    inputs[h].add(w)

    if h_l[h] :
        h_l[h][1].add(w)
        h_l[h][0] += 1
    else:
        h_l[h] = [1, set([w])]
        
    if h_l[h][0] > max_h:
        max_h_l = [h]
        max_h = h_l[h][0]
    elif h_l[h][0] == max_h:
        max_h_l.append(h)
 
        
    if w_l[w]:
        w_l[w][1].add(h)
        w_l[w][0] += 1
    else:
        w_l[w] = [1, set([h])]
    if w_l[w][0] > max_w:
        max_w_l = [w]
        max_w = w_l[w][0]
    elif w_l[w][0] == max_w:
        max_w_l.append(w)

ans = max_h + max_w -1
flag = 0
for i in max_h_l:
    if flag == 1:
        break
    for j in max_w_l:
        if j not in inputs[i]:
            ans = max_h + max_w
            flag = 1
            break
        
print(ans)
# Original solution
import sys

H, W, M = list(map(int, sys.stdin.readline().strip().split()))

h = [0] * H
w = [0] * W

g = [[False] * W for _ in range(H)]
S = set()
for _ in range(M):
    Th, Tw = list(map(int, sys.stdin.readline().strip().split()))

    h[Th - 1] += 1
    w[Tw - 1] += 1

    # g[Th - 1][Tw - 1] = True
    S.add((Th - 1, Tw - 1))

max_h = max(h)
max_w = max(w)
ans = max_h + max_w

index_h = [n for n, v in enumerate(h) if v == max_h]
index_w = [n for n, v in enumerate(w) if v == max_w]

sub = 1
# for ih in index_h:
#     for iv in index_w:
#         if g[ih][iv] is False:
#             sub = 0
#             break
#     else:
#         continue
#     break
# ans -= sub
# print(ans)


for ih in index_h:
    for iv in index_w:
        if not (ih, iv) in S:
            print(ans)
            exit()
print((ans - 1))



# Optimized solution
import sys

H, W, M = list(map(int, sys.stdin.readline().strip().split()))

h = [0] * H
w = [0] * W

# g = [[False] * W for _ in range(H)]
S = set()
for _ in range(M):
    Th, Tw = list(map(int, sys.stdin.readline().strip().split()))

    h[Th - 1] += 1
    w[Tw - 1] += 1

    # g[Th - 1][Tw - 1] = True
    S.add((Th - 1, Tw - 1))

max_h = max(h)
max_w = max(w)
ans = max_h + max_w

index_h = [n for n, v in enumerate(h) if v == max_h]
index_w = [n for n, v in enumerate(w) if v == max_w]

sub = 1
# for ih in index_h:
#     for iv in index_w:
#         if g[ih][iv] is False:
#             sub = 0
#             break
#     else:
#         continue
#     break
# ans -= sub
# print(ans)


for ih in index_h:
    for iv in index_w:
        if not (ih, iv) in S:
            print(ans)
            exit()
print((ans - 1))
# Original solution

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

hw_map = [[0 for i in range(w)] for j in range(h)]
h_bomb_list = [0 for i in range(h)]
w_bomb_list = [0 for i in range(w)]

for i in range(m):
  bh, bw = list(map(int, input().split()))
  hw_map[bh-1][bw-1] = 1
  h_bomb_list[bh-1] += 1
  w_bomb_list[bw-1] += 1
  

h_max = max(h_bomb_list)
h_argmax = max(list(zip(h_bomb_list, list(range(len(h_bomb_list))))))[1]
w_max = max([w_bomb_list[i] - hw_map[h_argmax][i] for i in range(w)])
print((int(h_max+w_max)))



# Optimized solution

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

h_b_list = [0 for i in range(h)]
w_b_list = [0 for i in range(w)]

targets = []
for i in range(m):
  bh, bw = list(map(int, input().split()))
  targets.append([bh, bw])
  h_b_list[bh-1] += 1
  w_b_list[bw-1] += 1
  
h_max = max(h_b_list)
w_max = max(w_b_list)

h_cans = []
w_cans = []
for i in range(h):
  if h_b_list[i] == h_max:
    h_cans.append(i)
    
for i in range(w):
  if w_b_list[i] == w_max:
    w_cans.append(i)

for hi in h_cans:
  for wi in w_cans:
    if [hi+1, wi+1] not in targets:
      print((h_max+w_max))
      exit()
else:
  print((h_max+w_max-1))
# Original solution
import sys
from bisect import bisect_left as bl
input = sys.stdin.readline
H, W, N = list(map(int, input().split()))
ys = [0] * (H + 1)
xs = [0] * (W + 1)
a = []
base = 10 ** 6
for i in range(N):
  y, x = list(map(int, input().split()))
  ys[y] += 1
  xs[x] += 1
  a.append((y, x))
sy = sorted(ys[1: ])
sx = sorted(xs[1: ])
#print(sy, sx)
def check(k):
  res = 0
  for y, x in a:
    res -= (ys[y] + xs[x]) == k
    res += (ys[y] + xs[x]) > k

  #print(res, k)
  for y in sy:
    i = bl(sx, k - y)
    res += W - i
    #print(W - i, y, k, res)
  return res > 0

ok = 0
ng = N + 1
while ng - ok > 1:
  m = (ok + ng) // 2
  if check(m): ok = m
  else: ng = m
print(ok)

# Optimized solution
import sys
input = sys.stdin.readline
H, W, M = list(map(int, input().split()))
s = set()
ys = [0] * (H + 1)
xs = [0] * (W + 1)
for _ in range(M):
  y, x = list(map(int, input().split()))
  s.add((y, x))
  ys[y] += 1
  xs[x] += 1

res = 0
mxy = []
mx = max(ys)
for i in range(H + 1):
  if ys[i] == mx: mxy.append(i)
res += mx

mxx = []
mx = max(xs)
for i in range(W + 1):
  if xs[i] == mx: mxx.append(i)
res += mx - 1

for x in mxx:
  for y in mxy:
    if (y, x) in s: continue
    res += 1
    break
  else: continue
  break
print(res)
# Original solution
h,w,m=list(map(int,input().split()))
bomb=[list(map(int,input().split())) for i in range(m)]

num_h = [0] * (h+1)
num_w = [0] * (w+1)
bomb_set = set()
for hi,wi in bomb:
  num_h[hi] += 1
  num_w[wi] += 1
  bomb_set.add((hi,wi))
  
max_hs = [k for k,v in enumerate(num_h) if v == max(num_h)]
max_ws = [k for k,v in enumerate(num_w) if v == max(num_w)]

result = max(num_h) + max(num_w)
for i in max_hs:
  for j in max_ws:
    if (i,j) not in bomb_set:
      print(result)
      exit(0)
print((result-1))


# Optimized solution
h,w,m=list(map(int,input().split()))
bomb=[list(map(int,input().split())) for i in range(m)]

num_h = [0] * (h+1)
num_w = [0] * (w+1)
bomb_set = set()
for hi,wi in bomb:
  num_h[hi] += 1
  num_w[wi] += 1
  bomb_set.add((hi,wi))
  
max_h = max(num_h)
max_w = max(num_w)
max_hs = [k for k,v in enumerate(num_h) if v == max_h]
max_ws = [k for k,v in enumerate(num_w) if v == max_w]

result = max_h + max_w
for i in max_hs:
  for j in max_ws:
    if (i,j) not in bomb_set:
      print(result)
      exit(0)
print((result-1))
# Original solution
from itertools import product
from sys import exit

def maxindexes(L,Lmax):
    ret = []
    for i in range(len(L)):
        if L[i] == Lmax:
            ret.append(i)
    
    return ret


H,W,M = list(map(int,input().split()))
row = [0]*H
col = [0]*W
bomb = []

for _ in range(M):
    a,b = (int(x)-1 for x in input().split())
    row[a] += 1
    col[b] += 1
    bomb.append((a,b))

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

rmaxind= maxindexes(row,rmax)
cmaxind = maxindexes(col,cmax)

for p in product(rmaxind,cmaxind):
    if p not in bomb:
        print((rmax+cmax))
        exit(0)

print((rmax+cmax-1))

# Optimized solution
from itertools import product
from sys import exit

def maxindexes(L,Lmax):
    ret = []
    for i in range(len(L)):
        if L[i] == Lmax:
            ret.append(i)
    
    return ret


H,W,M = list(map(int,input().split()))
row = [0]*H
col = [0]*W
bomb = set([])

for _ in range(M):
    a,b = (int(x)-1 for x in input().split())
    row[a] += 1
    col[b] += 1
    bomb.add((a,b))

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

rmaxind= maxindexes(row,rmax)
cmaxind = maxindexes(col,cmax)
prod = product(rmaxind,cmaxind)

for p in prod:
    if p not in bomb:
        print((rmax+cmax))
        exit(0)

print((rmax+cmax-1))
# Original solution
import sys
h,w,m = list(map(int,input().split()))
h_lst = [0]*h
w_lst = [0]*w
memo = []

for i in range(m):
  x,y = list(map(int,input().split()))
  h_lst[x-1] += 1
  w_lst[y-1] += 1
  memo.append((x-1,y-1))

sh = 0
for i in range(h):
  if h_lst[i] > sh:
    sh = h_lst[i]
sw = 0
for i in range(w):
  if w_lst[i] > sw:
    sw = w_lst[i]



memo = set(memo)
              

for i in range(h):
  if h_lst[i] == sh:
    for j in range(w):
      if (i,j) not in memo and w_lst[j] == sw:
        print((sh+sw))
        sys.exit()
print(((sh+sw)-1))        
  

# Optimized solution
import sys
h,w,m = list(map(int,input().split()))
h_lst = [[0,i] for i in range(h)]
w_lst = [[0,i] for i in range(w)]
memo = []

for i in range(m):
  x,y = list(map(int,input().split()))
  h_lst[x-1][0] += 1
  w_lst[y-1][0] += 1
  memo.append((x-1,y-1))

h_lst.sort(reverse = True)
w_lst.sort(reverse = True)
Max_h = h_lst[0][0]
Max_w = w_lst[0][0]
h_ans = [h_lst[0][1]]
w_ans = [w_lst[0][1]]
if h != 1:
  s = 1
  while s < h and h_lst[s][0] == Max_h:
    h_ans.append(h_lst[s][1])
    s+= 1  
if w!= 1:  
  t=1  
  while t < w and w_lst[t][0] == Max_w:
    w_ans.append(w_lst[t][1])
    t += 1
  

memo = set(memo)

#探索するリストは、最大を取るものの集合でなければ計算量はO(m)にはならない！             
for j in h_ans:
  for k in w_ans:
    if (j,k) not in memo:
      print((Max_h+Max_w))
      sys.exit()
print(((Max_h+Max_w)-1))