#from random import randint

def f(h,w,m,ins):
    yp = [0]*h
    xp = [0]*w
    s = set()
    for hi,wi in ins:
        s.add((hi-1,wi-1))
        yp[hi-1] += 1
        xp[wi-1] += 1
    ypm = max(yp)
    xpm = max(xp)
    yps = [i for i in range(h) if yp[i] == ypm]
    xps = [i for i in range(w) if xp[i] == xpm]
    ans = ypm+xpm
    for ypsi in yps:
        for xpsi in xps:
            if not (ypsi,xpsi) in s:
                return ans
    return ans-1

if __name__ == "__main__":
    if False:
        while True:
            h,w = randint(1,10**5*3),randint(10**5,10**5*3)
            m = randint(1,min(h*w,10**5*3))
            ins = [(randint(1,h),randint(1,w)) for i in range(m)]
            ans = f(h,w,m,ins)
            print(ans)
    else:
        h,w,m = map(int,input().split())
        ans = f(h,w,m,[list(map(int,input().split())) for i in range(m)])
        print(ans) def f(h,w,m,ins):
    yp = [0]*h
    xp = [0]*w
    s = set()
    for hi,wi in ins:
        s.add((hi-1,wi-1))
        yp[hi-1] += 1
        xp[wi-1] += 1
    ypm = max(yp)
    xpm = max(xp)
    yps = [i for i in range(h) if yp[i] == ypm]
    xps = [i for i in range(w) if xp[i] == xpm]
    ans = ypm+xpm
    for ypsi in yps:
        for xpsi in xps:
            if not (ypsi,xpsi) in s:
                return ans
    return ans-1 f yp = [0]*h yp [0]*h [0] 0 h xp = [0]*w xp [0]*w [0] 0 w s = set() s set() set for hi,wi in ins:
        s.add((hi-1,wi-1))
        yp[hi-1] += 1
        xp[wi-1] += 1
     hi wi ins s.add((hi-1,wi-1)) s.add s add (hi-1,wi-1) hi-1 hi 1 wi-1 wi 1 yp[hi-1] += 1 yp[hi-1] yp hi-1 hi 1 1 xp[wi-1] += 1 xp[wi-1] xp wi-1 wi 1 1 ypm = max(yp) ypm max(yp) max yp xpm = max(xp) xpm max(xp) max xp i for i in range(h) if yp[i] == ypm for i in range(h) if yp[i] == ypm i range(h) range h yp[i] == ypm yp[i] yp i ypm if yp[i] == ypm i yps = [i for i in range(h) if yp[i] == ypm] yps [i for i in range(h) if yp[i] == ypm] i for i in range(w) if xp[i] == xpm for i in range(w) if xp[i] == xpm i range(w) range w xp[i] == xpm xp[i] xp i xpm if xp[i] == xpm i xps = [i for i in range(w) if xp[i] == xpm] xps [i for i in range(w) if xp[i] == xpm] ans = ypm+xpm ans ypm+xpm ypm xpm for ypsi in yps:
        for xpsi in xps:
            if not (ypsi,xpsi) in s:
                return ans
     ypsi yps for xpsi in xps:
            if not (ypsi,xpsi) in s:
                return ans
     xpsi xps if not (ypsi,xpsi) in s:
                return ans
     not (ypsi,xpsi) in s (ypsi,xpsi) in s (ypsi,xpsi) ypsi xpsi s return ans ans return ans-1 ans-1 ans 1 h h w w m m ins ins if __name__ == "__main__":
    if False:
        while True:
            h,w = randint(1,10**5*3),randint(10**5,10**5*3)
            m = randint(1,min(h*w,10**5*3))
            ins = [(randint(1,h),randint(1,w)) for i in range(m)]
            ans = f(h,w,m,ins)
            print(ans)
    else:
        h,w,m = map(int,input().split())
        ans = f(h,w,m,[list(map(int,input().split())) for i in range(m)])
        print(ans) __name__ == "__main__" __name__ "__main__" if False:
        while True:
            h,w = randint(1,10**5*3),randint(10**5,10**5*3)
            m = randint(1,min(h*w,10**5*3))
            ins = [(randint(1,h),randint(1,w)) for i in range(m)]
            ans = f(h,w,m,ins)
            print(ans)
    else:
        h,w,m = map(int,input().split())
        ans = f(h,w,m,[list(map(int,input().split())) for i in range(m)])
        print(ans) False while True:
            h,w = randint(1,10**5*3),randint(10**5,10**5*3)
            m = randint(1,min(h*w,10**5*3))
            ins = [(randint(1,h),randint(1,w)) for i in range(m)]
            ans = f(h,w,m,ins)
            print(ans)
     True h,w = randint(1,10**5*3),randint(10**5,10**5*3) h randint(1,10**5*3) randint 1 10**5*3 10**5 10 5 3 w randint(10**5,10**5*3) randint 10**5 10 5 10**5*3 10**5 10 5 3 m = randint(1,min(h*w,10**5*3)) m randint(1,min(h*w,10**5*3)) randint 1 min(h*w,10**5*3) min h*w h w 10**5*3 10**5 10 5 3 (randint(1,h),randint(1,w)) for i in range(m) for i in range(m) i range(m) range m for i in range(m) (randint(1,h),randint(1,w)) randint(1,h) randint 1 h randint(1,w) randint 1 w ins = [(randint(1,h),randint(1,w)) for i in range(m)] ins [(randint(1,h),randint(1,w)) for i in range(m)] ans = f(h,w,m,ins) ans f(h,w,m,ins) f h w m ins print(ans) print ans h,w,m = map(int,input().split()) h map(int,input().split()) map int input().split() ().split () input split w m list(map(int,input().split())) for i in range(m) for i in range(m) i range(m) range m for i in range(m) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ans = f(h,w,m,[list(map(int,input().split())) for i in range(m)]) ans f(h,w,m,[list(map(int,input().split())) for i in range(m)]) f h w m [list(map(int,input().split())) for i in range(m)] print(ans) print ans h,w = randint(1,10**5*3),randint(10**5,10**5*3) randint(1,10**5*3) h w = randint(1,10**5*3),randint(10**5,10**5*3) randint(10**5,10**5*3) w ins = [(randint(1,h),randint(1,w)) for i in range(m)] [(randint(1,h),randint(1,w)) for i in range(m)] ins ans = f(h,w,m,ins) f(h,w,m,ins) ans m = randint(1,min(h*w,10**5*3)) randint(1,min(h*w,10**5*3)) m ans = f(h,w,m,[list(map(int,input().split())) for i in range(m)]) f(h,w,m,[list(map(int,input().split())) for i in range(m)]) ans def f(h,w,m,ins):
    yp = [0]*h
    xp = [0]*w
    s = set()
    for hi,wi in ins:
        s.add((hi-1,wi-1))
        yp[hi-1] += 1
        xp[wi-1] += 1
    ypm = max(yp)
    xpm = max(xp)
    yps = [i for i in range(h) if yp[i] == ypm]
    xps = [i for i in range(w) if xp[i] == xpm]
    ans = ypm+xpm
    for ypsi in yps:
        for xpsi in xps:
            if not (ypsi,xpsi) in s:
                return ans
    return ans-1 def f(h,w,m,ins):
    yp = [0]*h
    xp = [0]*w
    s = set()
    for hi,wi in ins:
        s.add((hi-1,wi-1))
        yp[hi-1] += 1
        xp[wi-1] += 1
    ypm = max(yp)
    xpm = max(xp)
    yps = [i for i in range(h) if yp[i] == ypm]
    xps = [i for i in range(w) if xp[i] == xpm]
    ans = ypm+xpm
    for ypsi in yps:
        for xpsi in xps:
            if not (ypsi,xpsi) in s:
                return ans
    return ans-1 f h,w,m = map(int,input().split()) map(int,input().split()) h w,m = map(int,input().split()) map(int,input().split()) w m = map(int,input().split()) map(int,input().split()) m
#from random import randint

def f(h,w,m,ins):
    yp = [0]*h
    xp = [0]*w
    s = set()
    for hi,wi in ins:
        s.add((hi-1,wi-1))
        yp[hi-1] += 1
        xp[wi-1] += 1
    ypm = max(yp)
    xpm = max(xp)
    yps = [i for i in range(h) if yp[i] == ypm]
    xps = [i for i in range(w) if xp[i] == xpm]
    ans = ypm+xpm
    for ypsi in yps:
        for xpsi in xps:
            if not (ypsi,xpsi) in s:
                return ans
    return ans-1

if __name__ == "__main__":
    if False:
        while True:
            h,w = randint(1,10**5*3),randint(10**5,10**5*3)
            m = randint(1,min(h*w,10**5*3))
            ins = [(randint(1,h),randint(1,w)) for i in range(m)]
            ans = f(h,w,m,ins)
            print(ans)
    else:
        h,w,m = map(int,input().split())
        ans = f(h,w,m,[list(map(int,input().split())) for i in range(m)])
        print(ans)
