h,w,m=map(int,input().split())
s=[0]*m
t=[0]*m
temp=set()
for i in range(m):
  sm,tm=map(int,input().split())
  s[i]=sm
  t[i]=tm
  temp.add((s[i],t[i]))
st=[0]*h
tt=[0]*w
for i in range(m):
  st[s[i]-1]=st[s[i]-1]+1
  tt[t[i]-1]=tt[t[i]-1]+1
smax=max(st)
tmax=max(tt)
ans=smax+tmax
maxs=[]
maxt=[]
for i in range(h):
  if st[i]==smax:
    maxs.append(i)
for i in range(w):
  if tt[i]==tmax:
    maxt.append(i)

if len(maxs)*len(maxt)>m:
  print(ans)
else:
  for i in range(len(maxs)):
    for j in range(len(maxt)):
      if (maxs[i]+1,maxt[j]+1) not in temp:
        print(ans)
        exit()
  else:
    print(ans-1) h,w,m=map(int,input().split()) h map(int,input().split()) map int input().split() ().split () input split w m s=[0]*m s [0]*m [0] 0 m t=[0]*m t [0]*m [0] 0 m temp=set() temp set() set for i in range(m):
  sm,tm=map(int,input().split())
  s[i]=sm
  t[i]=tm
  temp.add((s[i],t[i])) i range(m) range m sm,tm=map(int,input().split()) sm map(int,input().split()) map int input().split() ().split () input split tm s[i]=sm s[i] s i sm t[i]=tm t[i] t i tm temp.add((s[i],t[i])) temp.add temp add (s[i],t[i]) s[i] s i t[i] t i st=[0]*h st [0]*h [0] 0 h tt=[0]*w tt [0]*w [0] 0 w for i in range(m):
  st[s[i]-1]=st[s[i]-1]+1
  tt[t[i]-1]=tt[t[i]-1]+1 i range(m) range m st[s[i]-1]=st[s[i]-1]+1 st[s[i]-1] st s[i]-1 s[i] s i 1 st[s[i]-1]+1 st[s[i]-1] st s[i]-1 s[i] s i 1 1 tt[t[i]-1]=tt[t[i]-1]+1 tt[t[i]-1] tt t[i]-1 t[i] t i 1 tt[t[i]-1]+1 tt[t[i]-1] tt t[i]-1 t[i] t i 1 1 smax=max(st) smax max(st) max st tmax=max(tt) tmax max(tt) max tt ans=smax+tmax ans smax+tmax smax tmax maxs=[] maxs [] maxt=[] maxt [] for i in range(h):
  if st[i]==smax:
    maxs.append(i) i range(h) range h if st[i]==smax:
    maxs.append(i) st[i]==smax st[i] st i smax maxs.append(i) maxs.append maxs append i for i in range(w):
  if tt[i]==tmax:
    maxt.append(i) i range(w) range w if tt[i]==tmax:
    maxt.append(i) tt[i]==tmax tt[i] tt i tmax maxt.append(i) maxt.append maxt append i if len(maxs)*len(maxt)>m:
  print(ans)
else:
  for i in range(len(maxs)):
    for j in range(len(maxt)):
      if (maxs[i]+1,maxt[j]+1) not in temp:
        print(ans)
        exit()
  else:
    print(ans-1) len(maxs)*len(maxt)>m len(maxs)*len(maxt) len(maxs) len maxs len(maxt) len maxt m print(ans) print ans for i in range(len(maxs)):
    for j in range(len(maxt)):
      if (maxs[i]+1,maxt[j]+1) not in temp:
        print(ans)
        exit()
  else:
    print(ans-1) i range(len(maxs)) range len(maxs) len maxs for j in range(len(maxt)):
      if (maxs[i]+1,maxt[j]+1) not in temp:
        print(ans)
        exit()
   j range(len(maxt)) range len(maxt) len maxt if (maxs[i]+1,maxt[j]+1) not in temp:
        print(ans)
        exit()
   (maxs[i]+1,maxt[j]+1) not in temp (maxs[i]+1,maxt[j]+1) maxs[i]+1 maxs[i] maxs i 1 maxt[j]+1 maxt[j] maxt j 1 temp print(ans) print ans exit() exit print(ans-1) print ans-1 ans 1 tmax=max(tt) max(tt) tmax ans=smax+tmax smax+tmax ans temp=set() set() temp tm=map(int,input().split()) map(int,input().split()) tm h,w,m=map(int,input().split()) map(int,input().split()) h w,m=map(int,input().split()) map(int,input().split()) w t=[0]*m [0]*m t maxs=[] [] maxs st=[0]*h [0]*h st tt=[0]*w [0]*w tt smax=max(st) max(st) smax m=map(int,input().split()) map(int,input().split()) m sm,tm=map(int,input().split()) map(int,input().split()) sm maxt=[] [] maxt s=[0]*m [0]*m s
h,w,m=map(int,input().split())
s=[0]*m
t=[0]*m
temp=set()
for i in range(m):
  sm,tm=map(int,input().split())
  s[i]=sm
  t[i]=tm
  temp.add((s[i],t[i]))
st=[0]*h
tt=[0]*w
for i in range(m):
  st[s[i]-1]=st[s[i]-1]+1
  tt[t[i]-1]=tt[t[i]-1]+1
smax=max(st)
tmax=max(tt)
ans=smax+tmax
maxs=[]
maxt=[]
for i in range(h):
  if st[i]==smax:
    maxs.append(i)
for i in range(w):
  if tt[i]==tmax:
    maxt.append(i)

if len(maxs)*len(maxt)>m:
  print(ans)
else:
  for i in range(len(maxs)):
    for j in range(len(maxt)):
      if (maxs[i]+1,maxt[j]+1) not in temp:
        print(ans)
        exit()
  else:
    print(ans-1)