Buggy python submission (verdict: Time Limit Exceeded):
import sys
H, W, M = map(int, input().split())
lis =[]
Hlis = [0]*H
Wlis = [0]*W
for _ in range(M):
    Ch, Cm = map(int, input().split())
    Hlis[Ch-1] += 1
    Wlis[Cm-1] += 1
    lis.append([Ch, Cm])

Hmax = max(Hlis)
Hidx = [i+1 for i, v in enumerate(Hlis) if v == Hmax]
Wmax = max(Wlis)
Widx = [i+1 for i, v in enumerate(Wlis) if v == Wmax]

lis=tuple(lis)

for i in range(len(Hidx)):
    for j in range(len(Widx)):
        if [Hidx[i], Widx[j]] not in lis:
            print(Hmax+Wmax)
            sys.exit()
else:
    print(Hmax + Wmax -1)

Fixed submission:
import sys
H, W, M = map(int, input().split())
lis =set()
Hlis = [0]*H
Wlis = [0]*W
for _ in range(M):
    Ch, Cm = map(int, input().split())
    Hlis[Ch-1] += 1
    Wlis[Cm-1] += 1
    lis.add((Ch, Cm))

Hmax = max(Hlis)
Hidx = [i+1 for i, v in enumerate(Hlis) if v == Hmax]
Wmax = max(Wlis)
Widx = [i+1 for i, v in enumerate(Wlis) if v == Wmax]

for i in range(len(Hidx)):
    for j in range(len(Widx)):
        if (Hidx[i], Widx[j]) not in lis:
            print(Hmax+Wmax)
            sys.exit()
else:
    print(Hmax + Wmax -1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
H, W, M = map(int, input().split())
lis =[]
Hlis = [0]*H
Wlis = [0]*W
for _ in range(M):
    Ch, Cm = map(int, input().split())
    Hlis[Ch-1] += 1
    Wlis[Cm-1] += 1
    lis.append([Ch, Cm])

Hmax = max(Hlis)
Hidx = [i+1 for i, v in enumerate(Hlis) if v == Hmax]
Wmax = max(Wlis)
Widx = [i+1 for i, v in enumerate(Wlis) if v == Wmax]

for i in range(len(Hidx)):
    for j in range(len(Widx)):
        if [Hidx[i], Widx[j]] not in lis:
            print(Hmax+Wmax)
            sys.exit()
else:
    print(Hmax + Wmax -1)

Fixed submission:
import sys
H, W, M = map(int, input().split())
lis =set()
Hlis = [0]*H
Wlis = [0]*W
for _ in range(M):
    Ch, Cm = map(int, input().split())
    Hlis[Ch-1] += 1
    Wlis[Cm-1] += 1
    lis.add((Ch, Cm))

Hmax = max(Hlis)
Hidx = [i+1 for i, v in enumerate(Hlis) if v == Hmax]
Wmax = max(Wlis)
Widx = [i+1 for i, v in enumerate(Wlis) if v == Wmax]

for i in range(len(Hidx)):
    for j in range(len(Widx)):
        if (Hidx[i], Widx[j]) not in lis:
            print(Hmax+Wmax)
            sys.exit()
else:
    print(Hmax + Wmax -1)

Buggy python submission (verdict: Runtime Error):
import sys
H, W, M = map(int, input().split())
lis =[]
Hlis = [0]*H
Mlis = [0]*M
for _ in range(M):
    Ch, Cm = map(int, input().split())
    Hlis[Ch-1] += 1
    Mlis[Cm-1] += 1
    lis.append([Ch, Cm])

Hmax = max(Hlis)
Hidx = [i+1 for i, v in enumerate(Hlis) if v == Hmax]
Mmax = max(Mlis)
Midx = [i+1 for i, v in enumerate(Mlis) if v == Mmax]

for i in range(len(Hidx)):
    for j in range(len(Midx)):
        if [Hidx[i], Midx[j]] not in lis:
            print(Hmax+Mmax)
            sys.exit()
else:
    print(Hmax + Mmax -1)

Fixed submission:
import sys
H, W, M = map(int, input().split())
lis =set()
Hlis = [0]*H
Wlis = [0]*W
for _ in range(M):
    Ch, Cm = map(int, input().split())
    Hlis[Ch-1] += 1
    Wlis[Cm-1] += 1
    lis.add((Ch, Cm))

Hmax = max(Hlis)
Hidx = [i+1 for i, v in enumerate(Hlis) if v == Hmax]
Wmax = max(Wlis)
Widx = [i+1 for i, v in enumerate(Wlis) if v == Wmax]

for i in range(len(Hidx)):
    for j in range(len(Widx)):
        if (Hidx[i], Widx[j]) not in lis:
            print(Hmax+Wmax)
            sys.exit()
else:
    print(Hmax + Wmax -1)

Buggy python submission (verdict: Runtime Error):
import sys
H, W, M = map(int, input().split())
lis =[]
Hlis = [0]*H
Mlis = [0]*M
for _ in range(M):
    Ch, Cm = map(int, input().split())
    Hlis[Ch-1] += 1
    Mlis[Cm-1] += 1
    lis.append([Ch, Cm])

Hmax = max(Hlis)
Hidx = [i+1 for i, v in enumerate(Hlis) if v == Hmax]
Mmax = max(Mlis)
Midx = [i+1 for i, v in enumerate(Mlis) if v == Mmax]

for i in range(len(Hidx)):
    for j in range(len(Midx)):
        if [[Hidx, Midx]] not in lis:
            print(Hmax+Mmax)
            sys.exit()
else:
    print(Hmax + Mmax -1)

Fixed submission:
import sys
H, W, M = map(int, input().split())
lis =set()
Hlis = [0]*H
Wlis = [0]*W
for _ in range(M):
    Ch, Cm = map(int, input().split())
    Hlis[Ch-1] += 1
    Wlis[Cm-1] += 1
    lis.add((Ch, Cm))

Hmax = max(Hlis)
Hidx = [i+1 for i, v in enumerate(Hlis) if v == Hmax]
Wmax = max(Wlis)
Widx = [i+1 for i, v in enumerate(Wlis) if v == Wmax]

for i in range(len(Hidx)):
    for j in range(len(Widx)):
        if (Hidx[i], Widx[j]) not in lis:
            print(Hmax+Wmax)
            sys.exit()
else:
    print(Hmax + Wmax -1)

Buggy python submission (verdict: Runtime Error):
H, W, M = map(int, input().split())
lis =[]
Hlis = [0]*H
Mlis = [0]*M
for _ in range(M):
    Ch, Cm = map(int, input().split())
    Hlis[Ch-1] += 1
    Mlis[Cm-1] += 1
    lis.append([Ch, Cm])

Hmax = max(Hlis)
Hidx = [i+1 for i, v in enumerate(Hlis) if v == Hmax]
Mmax = max(Mlis)
Midx = [i+1 for i, v in enumerate(Mlis) if v == Mmax]

if [Hidx, Midx] in lis:
    print(Hmax + Mmax -1)
else:
    print(Hmax+Mmax)
          

Fixed submission:
import sys
H, W, M = map(int, input().split())
lis =set()
Hlis = [0]*H
Wlis = [0]*W
for _ in range(M):
    Ch, Cm = map(int, input().split())
    Hlis[Ch-1] += 1
    Wlis[Cm-1] += 1
    lis.add((Ch, Cm))

Hmax = max(Hlis)
Hidx = [i+1 for i, v in enumerate(Hlis) if v == Hmax]
Wmax = max(Wlis)
Widx = [i+1 for i, v in enumerate(Wlis) if v == Wmax]

for i in range(len(Hidx)):
    for j in range(len(Widx)):
        if (Hidx[i], Widx[j]) not in lis:
            print(Hmax+Wmax)
            sys.exit()
else:
    print(Hmax + Wmax -1)

Buggy python submission (verdict: Runtime Error):
H, W, M = map(int, input().split())
lis =[]
Hlis = [0]*H
Mlis = [0]*M
for _ in range(M):
    Ch, Cm = map(int, input().split())
    Hlis[Ch-1] += 1
    Mlis[Cm-1] += 1
    lis.append([Ch, Cm])

Hmax = max(Hlis)
Hidx = Hlis.index(Hmax)+1
Mmax = max(Mlis)
Midx = Mlis.index(Mmax)+1

if [Hidx, Midx] in lis:
    print(Hmax + Mmax -1)
else:
    print(Hmax+Mmax)

Fixed submission:
import sys
H, W, M = map(int, input().split())
lis =set()
Hlis = [0]*H
Wlis = [0]*W
for _ in range(M):
    Ch, Cm = map(int, input().split())
    Hlis[Ch-1] += 1
    Wlis[Cm-1] += 1
    lis.add((Ch, Cm))

Hmax = max(Hlis)
Hidx = [i+1 for i, v in enumerate(Hlis) if v == Hmax]
Wmax = max(Wlis)
Widx = [i+1 for i, v in enumerate(Wlis) if v == Wmax]

for i in range(len(Hidx)):
    for j in range(len(Widx)):
        if (Hidx[i], Widx[j]) not in lis:
            print(Hmax+Wmax)
            sys.exit()
else:
    print(Hmax + Wmax -1)