from collections import defaultdict as ddict



ii=jj=0

ia,ja=[],[]

rows=ddict(int)

cols=ddict(int)

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

tgts=set()

for _ in range(M):

    i,j=list(map(int,input().split()))

    tgts.add((i,j))



    rows[i]+=1

    cols[j]+=1

    x=rows[i]

    if x>ii:

        ii=x

        ia=[i]

    elif x==ii:

        ia.append(i)

    y=cols[j]

    if y>jj:

        jj=y

        ja=[j]

    elif y==jj:

        ja.append(j)







ans=0

for i in ia:

    for j in ja:

        k=rows[i]+cols[j]

        if (i,j) in tgts:

            k-=1

        else:

            ans=k

            break

        ans=max(ans,k)



print(ans)

from collections import defaultdict as ddict



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



xs=[0]*w

ys=[0]*h

xsmx=ysmx=0

pts=set()

for _ in range(m):

    y,x=list(map(int,input().split()))

    x,y=x-1,y-1

    xs[x]+=1

    ys[y]+=1

    pts.add((x,y))

    xsmx=max(xsmx,xs[x])

    ysmx=max(ysmx,ys[y])



xsc=[x for x in range(w) if xs[x]==xsmx]

ysc=[y for y in range(h) if ys[y]==ysmx]

ans=xsmx+ysmx-1

ok=False

for y in ysc:

    for x in xsc:

        if (x,y) not in pts:

            ans+=1

            ok=True

            break

    if ok:

        break



print(ans)

from collections import defaultdict as ddict

ii = jj = 0
ia, ja = [], []
rows = ddict(int)
cols = ddict(int)
H, W, M = list(map(int, input().split()))
tgts = set()
for _ in range(M):
    i, j = list(map(int, input().split()))
    tgts.add((i, j))
    rows[i] += 1
    cols[j] += 1
    x = rows[i]
    if x > ii:
        ii = x
        ia = [i]
    elif x == ii:
        ia.append(i)
    y = cols[j]
    if y > jj:
        jj = y
        ja = [j]
    elif y == jj:
        ja.append(j)
ans = 0
for i in ia:
    for j in ja:
        k = rows[i] + cols[j]
        if (i, j) in tgts:
            k -= 1
        else:
            ans = k
            break
        ans = max(ans, k)
print(ans)

from collections import defaultdict as ddict

h, w, m = list(map(int, input().split()))
xs = [0] * w
ys = [0] * h
xsmx = ysmx = 0
pts = set()
for _ in range(m):
    y, x = list(map(int, input().split()))
    x, y = x - 1, y - 1
    xs[x] += 1
    ys[y] += 1
    pts.add((x, y))
    xsmx = max(xsmx, xs[x])
    ysmx = max(ysmx, ys[y])
xsc = [x for x in range(w) if xs[x] == xsmx]
ysc = [y for y in range(h) if ys[y] == ysmx]
ans = xsmx + ysmx - 1
ok = False
for y in ysc:
    for x in xsc:
        if (x, y) not in pts:
            ans += 1
            ok = True
            break
    if ok:
        break
print(ans)

-ii = jj = 0 -ia, ja = [], [] -rows = ddict(int) -cols = ddict(int) -H, W, M = list(map(int, input().split())) -tgts = set() -for _ in range(M): -    i, j = list(map(int, input().split())) -    tgts.add((i, j)) -    rows[i] += 1 -    cols[j] += 1 -    x = rows[i] -    if x > ii: -        ii = x -        ia = [i] -    elif x == ii: -        ia.append(i) -    y = cols[j] -    if y > jj: -        jj = y -        ja = [j] -    elif y == jj: -        ja.append(j) -ans = 0 -for i in ia: -    for j in ja: -        k = rows[i] + cols[j] -        if (i, j) in tgts: -            k -= 1 -        else: -            ans = k +h, w, m = list(map(int, input().split())) +xs = [0] * w +ys = [0] * h +xsmx = ysmx = 0 +pts = set() +for _ in range(m): +    y, x = list(map(int, input().split())) +    x, y = x - 1, y - 1 +    xs[x] += 1 +    ys[y] += 1 +    pts.add((x, y)) +    xsmx = max(xsmx, xs[x]) +    ysmx = max(ysmx, ys[y]) +xsc = [x for x in range(w) if xs[x] == xsmx] +ysc = [y for y in range(h) if ys[y] == ysmx] +ans = xsmx + ysmx - 1 +ok = False +for y in ysc: +    for x in xsc: +        if (x, y) not in pts: +            ans += 1 +            ok = True -        ans = max(ans, k) +    if ok: +        break