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

countH = [[h, 0] for h in range(H)]

countW = [[w, 0] for w in range(W)]

Bh = {}



for i in range(M):

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

  h, w = h-1, w-1

  if h in Bh:

    Bh[h].add(w)

  else:

    Bh[h] = {w}

  countH[h][1] += 1

  countW[w][1] += 1



countH.sort(reverse=True, key=lambda x: x[1])

countW.sort(reverse=True, key=lambda x: x[1])

#print(countH)

#print(countW)

#rint(Bh)



maxh = countH[0][1]

maxw = countW[0][1]

ans = maxh + maxw

ch = [countH[0][0]]

i = 1

while i < H and countH[i][1]==maxh:

  ch.append(countH[i][0])

  i += 1

cw = [countW[0][0]]

i = 1

while i < W and countW[i][1]==maxw:

  cw.append(countW[i][0])

  i += 1

flag = False

for h in ch:

  for w in cw:

    #print(h,w)

    if w not in Bh[h]:

      flag = True

      break

if flag:

  print(ans)

else:

  print((ans-1))
H, W, M = list(map(int, input().split()))

countH = [0 for h in range(H)]

countW = [0 for w in range(W)]

Bh = {}



for i in range(M):

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

  h, w = h-1, w-1

  if h in Bh:

    Bh[h].add(w)

  else:

    Bh[h] = {w}

  countH[h] += 1

  countW[w] += 1



maxh = 0

ch = []

maxw = 0

cw = []

for i in range(H):

  if maxh==countH[i]:

    ch.append(i)

  elif maxh<countH[i]:

    ch = [i]

    maxh = countH[i]

for i in range(W):

  if maxw==countW[i]:

    cw.append(i)

  elif maxw<countW[i]:

    cw = [i]

    maxw = countW[i]



#print(countH)

#print(countW)

#rint(Bh)

ans = maxh + maxw

flag = False

for h in ch:

  for w in cw:

    #print(h,w)

    if w not in Bh[h]:

      flag = True

      break

if flag:

  print(ans)

else:

  print((ans-1))
H, W, M = list(map(int, input().split()))
countH = [[h, 0] for h in range(H)]
countW = [[w, 0] for w in range(W)]
Bh = {}
for i in range(M):
    h, w = list(map(int, input().split()))
    h, w = h - 1, w - 1
    if h in Bh:
        Bh[h].add(w)
    else:
        Bh[h] = {w}
    countH[h][1] += 1
    countW[w][1] += 1
countH.sort(reverse=True, key=lambda x: x[1])
countW.sort(reverse=True, key=lambda x: x[1])
# print(countH)
# print(countW)
# rint(Bh)
maxh = countH[0][1]
maxw = countW[0][1]
ans = maxh + maxw
ch = [countH[0][0]]
i = 1
while i < H and countH[i][1] == maxh:
    ch.append(countH[i][0])
    i += 1
cw = [countW[0][0]]
i = 1
while i < W and countW[i][1] == maxw:
    cw.append(countW[i][0])
    i += 1
flag = False
for h in ch:
    for w in cw:
        # print(h,w)
        if w not in Bh[h]:
            flag = True
            break
if flag:
    print(ans)
else:
    print((ans - 1))

H, W, M = list(map(int, input().split()))
countH = [0 for h in range(H)]
countW = [0 for w in range(W)]
Bh = {}
for i in range(M):
    h, w = list(map(int, input().split()))
    h, w = h - 1, w - 1
    if h in Bh:
        Bh[h].add(w)
    else:
        Bh[h] = {w}
    countH[h] += 1
    countW[w] += 1
maxh = 0
ch = []
maxw = 0
cw = []
for i in range(H):
    if maxh == countH[i]:
        ch.append(i)
    elif maxh < countH[i]:
        ch = [i]
        maxh = countH[i]
for i in range(W):
    if maxw == countW[i]:
        cw.append(i)
    elif maxw < countW[i]:
        cw = [i]
        maxw = countW[i]
# print(countH)
# print(countW)
# rint(Bh)
ans = maxh + maxw
flag = False
for h in ch:
    for w in cw:
        # print(h,w)
        if w not in Bh[h]:
            flag = True
            break
if flag:
    print(ans)
else:
    print((ans - 1))

-countH = [[h, 0] for h in range(H)] -countW = [[w, 0] for w in range(W)] +countH = [0 for h in range(H)] +countW = [0 for w in range(W)] -    countH[h][1] += 1 -    countW[w][1] += 1 -countH.sort(reverse=True, key=lambda x: x[1]) -countW.sort(reverse=True, key=lambda x: x[1]) +    countH[h] += 1 +    countW[w] += 1 +maxh = 0 +ch = [] +maxw = 0 +cw = [] +for i in range(H): +    if maxh == countH[i]: +        ch.append(i) +    elif maxh < countH[i]: +        ch = [i] +        maxh = countH[i] +for i in range(W): +    if maxw == countW[i]: +        cw.append(i) +    elif maxw < countW[i]: +        cw = [i] +        maxw = countW[i] -maxh = countH[0][1] -maxw = countW[0][1] -ch = [countH[0][0]] -i = 1 -while i < H and countH[i][1] == maxh: -    ch.append(countH[i][0]) -    i += 1 -cw = [countW[0][0]] -i = 1 -while i < W and countW[i][1] == maxw: -    cw.append(countW[i][0]) -    i += 1