(h,w,m),*e=[[*map(int,i.split())]for i in open(0)]
a,b=[0]*h,[0]*w
for y,x in e:
    a[y-1]+=1
    b[x-1]+=1
ans=max(a)+max(b)
c=a.count(max(a))*b.count(max(b))-sum(a[y-1]+b[x-1]==ans for y,x in e)
print(ans-(c<=0)) [*map(int,i.split())]for i in open(0) for i in open(0) i open(0) open 0 for i in open(0) [*map(int,i.split())] *map(int,i.split()) map(int,i.split()) map int i.split() i.split i split (h,w,m),*e=[[*map(int,i.split())]for i in open(0)] (h,w,m) h w m [[*map(int,i.split())]for i in open(0)] *e e a,b=[0]*h,[0]*w a [0]*h [0] 0 h b [0]*w [0] 0 w for y,x in e:
    a[y-1]+=1
    b[x-1]+=1 y x e a[y-1]+=1 a[y-1] a y-1 y 1 1 b[x-1]+=1 b[x-1] b x-1 x 1 1 ans=max(a)+max(b) ans max(a)+max(b) max(a) max a max(b) max b c=a.count(max(a))*b.count(max(b))-sum(a[y-1]+b[x-1]==ans for y,x in e) c a.count(max(a))*b.count(max(b))-sum(a[y-1]+b[x-1]==ans for y,x in e) a.count(max(a))*b.count(max(b)) a.count(max(a)) a.count a count max(a) max a b.count(max(b)) b.count b count max(b) max b sum(a[y-1]+b[x-1]==ans for y,x in e) sum a[y-1]+b[x-1]==ans a[y-1]+b[x-1] a[y-1] a y-1 y 1 b[x-1] b x-1 x 1 ans print(ans-(c<=0)) print ans-(c<=0) ans c<=0 c 0 c=a.count(max(a))*b.count(max(b))-sum(a[y-1]+b[x-1]==ans for y,x in e) a.count(max(a))*b.count(max(b))-sum(a[y-1]+b[x-1]==ans for y,x in e) c ans=max(a)+max(b) max(a)+max(b) ans a,b=[0]*h,[0]*w [0]*h a b=[0]*h,[0]*w [0]*w b
(h,w,m),*e=[[*map(int,i.split())]for i in open(0)]
a,b=[0]*h,[0]*w
for y,x in e:
    a[y-1]+=1
    b[x-1]+=1
ans=max(a)+max(b)
c=a.count(max(a))*b.count(max(b))-sum(a[y-1]+b[x-1]==ans for y,x in e)
print(ans-(c<=0))