Buggy python submission (verdict: Time Limit Exceeded):
h,w,m = map(int,input().split())
hli = [0]*h
wli = [0]*w
li = []
for i in range(m):
    a,b = map(int,input().split())
    li.append([a,b])
    hli[a-1] += 1
    wli[b-1] += 1
a = max(hli)
b = max(wli)
hli2 = []
wli2 = []
for i in range(h):
    if hli[i] == a:
        hli2.append(i+1)
for i in range(w):
    if wli[i] == b:
        wli2.append(i+1)
for i in hli2:
    for j in wli2:
        if [i,j] not in li:
            print(a + b)
            exit()
print(a + b - 1)

Fixed submission:
h,w,m = map(int,input().split())
hli = [0]*h
wli = [0]*w
li = []
liset = set()
for i in range(m):
    a,b = map(int,input().split())
    li.append([a,b])
    liset.add((a,b))
    hli[a-1] += 1
    wli[b-1] += 1
a = max(hli)
b = max(wli)
hli2 = []
wli2 = []
for i in range(h):
    if hli[i] == a:
        hli2.append(i+1)
for i in range(w):
    if wli[i] == b:
        wli2.append(i+1)
for i in hli2:
    for j in wli2:
        if (i,j) not in liset:
            print(a + b)
            exit()
print(a + b - 1)

Buggy python submission (verdict: Time Limit Exceeded):
h,w,m = map(int,input().split())
hli = [0]*h
wli = [0]*w
li = []
for i in range(m):
    a,b = map(int,input().split())
    li.append([a,b])
    hli[a-1] += 1
    wli[b-1] += 1
a = max(hli)
b = max(wli)
hli2 = []
wli2 = []
for i in range(h):
    if hli[i] == a:
        hli2.append(i+1)
for i in range(w):
    if wli[i] == b:
        wli2.append(i+1)
for i in hli2:
    for j in wli2:
        if [i,j] not in li:
            print(a + b)
            exit()
print(a + b - 1)

Fixed submission:
h,w,m = map(int,input().split())
hli = [0]*h
wli = [0]*w
li = []
liset = set()
for i in range(m):
    a,b = map(int,input().split())
    li.append([a,b])
    liset.add((a,b))
    hli[a-1] += 1
    wli[b-1] += 1
a = max(hli)
b = max(wli)
hli2 = []
wli2 = []
for i in range(h):
    if hli[i] == a:
        hli2.append(i+1)
for i in range(w):
    if wli[i] == b:
        wli2.append(i+1)
for i in hli2:
    for j in wli2:
        if (i,j) not in liset:
            print(a + b)
            exit()
print(a + b - 1)

Buggy python submission (verdict: Time Limit Exceeded):
h,w,m = map(int,input().split())
hli = [0]*h
wli = [0]*w
li = []
for i in range(m):
    a,b = map(int,input().split())
    li.append([a,b])
    hli[a-1] += 1
    wli[b-1] += 1
a = max(hli)
b = max(wli)
hli2 = []
wli2 = []
for i in range(h):
    if hli[i] == a:
        hli2.append(i+1)
for i in range(w):
    if wli[i] == b:
        wli2.append(i+1)
for i in range(len(hli2)):
    for j in range(len(wli2)):
        if [hli2[i],wli2[j]] not in li:
            print(a + b)
            exit()
print(a + b - 1)

Fixed submission:
h,w,m = map(int,input().split())
hli = [0]*h
wli = [0]*w
li = []
liset = set()
for i in range(m):
    a,b = map(int,input().split())
    li.append([a,b])
    liset.add((a,b))
    hli[a-1] += 1
    wli[b-1] += 1
a = max(hli)
b = max(wli)
hli2 = []
wli2 = []
for i in range(h):
    if hli[i] == a:
        hli2.append(i+1)
for i in range(w):
    if wli[i] == b:
        wli2.append(i+1)
for i in hli2:
    for j in wli2:
        if (i,j) not in liset:
            print(a + b)
            exit()
print(a + b - 1)