CodeEff/ECCO huggingface dataset:
# Original solution
import sys
HK,WK,M = list(map(int, input().split()))
W = [0] * (WK + 1)
H = [0] * (HK + 1)
HW = [[0 for i in range(WK+1)] for _ in range(HK+1)]
# 3*10^5

for i in range(M):
    h, w = list(map(int, input().split()))

    H[h] += 1
    W[w] += 1

    HW[h][w] = 1

answer = 0
HMAX = max(H)
WMAX = max(W)

HEMAX = H.count(HMAX)
WEMAX = W.count(WMAX)
if HEMAX * WEMAX > M:
    print((HMAX + WMAX))
    sys.exit(0)

HMAXES = [i for i, _ in enumerate(H) if _ == HMAX]
WMAXES = [i for i, _ in enumerate(W) if _ == WMAX]

# 3*10^5
answer = HMAX + WMAX
for h in HMAXES:
    for w in WMAXES:
        if HW[h][w] == 0:
            print(answer)
            sys.exit(0)
print((answer-1))

# Optimized solution
import sys
HK,WK,M = list(map(int, input().split()))
W = [0] * (WK + 1)
H = [0] * (HK + 1)
HW = {}
# 3*10^5

for i in range(M):
    h, w = list(map(int, input().split()))

    H[h] += 1
    W[w] += 1

    HW[(h,w)] = 1

answer = 0
HMAX = max(H)
WMAX = max(W)

HEMAX = H.count(HMAX)
WEMAX = W.count(WMAX)
if HEMAX * WEMAX > M:
    print((HMAX + WMAX))
    sys.exit(0)

HMAXES = [i for i, _ in enumerate(H) if _ == HMAX]
WMAXES = [i for i, _ in enumerate(W) if _ == WMAX]

# 3*10^5
answer = HMAX + WMAX
for h in HMAXES:
    for w in WMAXES:
        if not (h,w) in HW:
            print(answer)
            sys.exit(0)
print((answer-1))
# Original solution
def find():
    h,w,m=list(map(int,input().split()))
    idx=[]

    for i in range(m):
      var=list(map(int,input().split()))
      idx.append(var)


    r={}
    c={}
    maze=[[0 for j in range(w)]for i in range(h)]

    for i in idx:
      maze[i[0]-1][i[1]-1]=1
      r.setdefault(i[0]-1,0)
      r[i[0]-1]+=1
      c.setdefault(i[1]-1,0)
      c[i[1]-1]+=1

    ans=0
    maxval=0



    row=[]
    col=[]
    maxr=max(r.values())
    maxc=max(c.values())
    for i in range(h):
      r.setdefault(i,0)
      if r[i]==maxr:
        row.append(i)
      

    for j in range(w):
      c.setdefault(j,0)
      if c[j]==maxc:
        col.append(j)
    
    for i in row:
      for j in col:
        if(maze[i][j]==0):
          return maxc+maxr
         
        
    return maxc+maxr-1
 
print((find()))

# Optimized solution
def find():
    h,w,m=list(map(int,input().split()))
    idx=[]


    for i in range(m):
      var=list(map(int,input().split()))
      idx.append(var)


    r={}
    c={}
    #maze=[[0 for j in range(w)]for i in range(h)]
    mz={}

    for i in idx:
      mz.setdefault((i[0]-1,i[1]-1),0)
      mz[(i[0]-1,i[1]-1)]=1
      #maze[i[0]-1][i[1]-1]=1
      r.setdefault(i[0]-1,0)
      r[i[0]-1]+=1
      c.setdefault(i[1]-1,0)
      c[i[1]-1]+=1

    ans=0
    maxval=0



    row=[]
    col=[]
    maxr=max(r.values())
    maxc=max(c.values())
    for i in range(h):
      r.setdefault(i,0)
      if r[i]==maxr:
        row.append(i)
      

    for j in range(w):
      c.setdefault(j,0)
      if c[j]==maxc:
        col.append(j)
    
    for i in row:
      for j in col:
        mz.setdefault((i,j),0)
        if(mz[(i,j)]==0):
          return maxc+maxr
         
    return maxc+maxr-1
 
print((find()))
# Original solution
from collections import Counter
from itertools import groupby


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def ilen(ll):
    return sum(1 for _ in ll)


def solve():
    H, W, M = read_ints()
    hw = []
    for _ in range(M):
        hw.append(read_ints())
    hw.sort()

    max_ws = {}
    max_count_ws = 0
    for h, ws in groupby(hw, key=lambda pair: pair[0]):
        ws = list(ws)
        max_count_ws = max(max_count_ws, len(ws))
        max_ws[h] = [w for _, w in ws]

    ks = list(max_ws.keys())
    for k in ks:
        if len(max_ws[k]) < max_count_ws:
            del max_ws[k]

    hw.sort(key=lambda pair: pair[1])
    max_hs = {}
    max_count_hs = 0
    for w, hs in groupby(hw, key=lambda pair: pair[1]):
        hs = list(hs)
        max_count_hs = max(max_count_hs, len(hs))
        max_hs[w] = [h for h, _ in hs]

    ks = list(max_hs.keys())
    for k in ks:
        if len(max_hs[k]) < max_count_hs:
            del max_hs[k]

    counter = Counter()
    for v in list(max_hs.values()):
        counter += Counter(v)
    for k in list(max_ws.keys()):
        if counter[k] != len(max_hs):
            return max_count_ws+max_count_hs
    return max_count_ws+max_count_hs-1


if __name__ == '__main__':
    print((solve()))


# Optimized solution
from collections import Counter
from itertools import groupby


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def ilen(ll):
    return sum(1 for _ in ll)


def solve():
    H, W, M = read_ints()
    hw = []
    for _ in range(M):
        hw.append(tuple(read_ints()))
    hw.sort()

    rows = set()
    max_count_row = 0
    for h, ws in groupby(hw, key=lambda pair: pair[0]):
        count = ilen(ws)
        if count == max_count_row:
            rows.add(h)
        elif count > max_count_row:
            rows = set([h])
            max_count_row = count

    hw.sort(key=lambda pair: pair[1])
    cols = set()
    max_count_col = 0
    for w, hs in groupby(hw, key=lambda pair: pair[1]):
        count = ilen(hs)
        if count == max_count_col:
            cols.add(w)
        elif count > max_count_col:
            cols = set([w])
            max_count_col = count

    hw = set(hw)
    for h in rows:
        for w in cols:
            if (h, w) not in hw:
                return max_count_row+max_count_col
    return max_count_row+max_count_col-1


if __name__ == '__main__':
    print((solve()))
# Original solution
H, W, M = list(map(int, input().split()))
hlist = [0] * H
wlist = [0] * W
hw = [[0 for _ in range(W)] for _ in range(H)]
for i in range(M):
    h, w = list(map(int, input().split()))
    hlist[h - 1] += 1
    wlist[w - 1] += 1
    hw[h - 1][w - 1] = 1

hmax = max(hlist)
wmax = max(wlist)
hmaxlist = [i for i, v in enumerate(hlist) if v == hmax]
wmaxlist = [i for i, v in enumerate(wlist) if v == wmax]
cnt = -1
for i in hmaxlist:
    bf = False
    for j in wmaxlist:
        if hw[i][j] != 1:
            cnt = 0
            bf = True
            break
    if bf:
        break

print((hmax + wmax + cnt))

# Optimized solution
H, W, M = list(map(int, input().split()))
hlist = [0] * H
wlist = [0] * W
hw = set()
for i in range(M):
    h, w = list(map(int, input().split()))
    hlist[h - 1] += 1
    wlist[w - 1] += 1
    hw.add((h - 1, w - 1))

hmax = max(hlist)
wmax = max(wlist)
hmaxlist = [i for i, v in enumerate(hlist) if v == hmax]
wmaxlist = [i for i, v in enumerate(wlist) if v == wmax]
cnt = -1
for i in hmaxlist:
    bf = False
    for j in wmaxlist:
        if not (i, j) in hw:
            cnt = 0
            bf = True
            break
    if bf:
        break

print((hmax + wmax + cnt))
# Original solution
def main():
    H, W, M = (int(i) for i in input().split())
    hc = [0]*(H+1)
    wc = [0]*(W+1)
    maps = set()
    for _ in range(M):
        h, w = (int(i) for i in input().split())
        hc[h] += 1
        wc[w] += 1
        maps.add((h, w))
    mah = -1
    maw = -1
    hmaps = set()
    wmaps = set()
    for i, h in enumerate(hc):
        if mah < h:
            mah = h
            hmaps = {i}
        elif mah == h:
            hmaps.add(i)
    for i, w in enumerate(wc):
        if maw < w:
            maw = w
            wmaps = {i}
        elif maw == w:
            wmaps.add(i)
    ans = mah+maw
    aru = True

    for h in list(hmaps):
        for w in list(wmaps):
            if (h, w) not in maps:
                aru = False
                break
    if aru:
        print((ans - 1))
    else:
        print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    H, W, M = (int(i) for i in input().split())
    hc = [0]*(H+1)
    wc = [0]*(W+1)
    maps = set()
    for _ in range(M):
        h, w = (int(i) for i in input().split())
        hc[h] += 1
        wc[w] += 1
        maps.add((h, w))
    mah = -1
    maw = -1
    hmaps = set()
    wmaps = set()
    for i, h in enumerate(hc):
        if mah < h:
            mah = h
            hmaps = {i}
        elif mah == h:
            hmaps.add(i)
    for i, w in enumerate(wc):
        if maw < w:
            maw = w
            wmaps = {i}
        elif maw == w:
            wmaps.add(i)
    ans = mah+maw
    aru = True
    if len(hmaps) * len(wmaps) <= 5*10**6:
        for h in list(hmaps):
            for w in list(wmaps):
                if (h, w) not in maps:
                    aru = False
                    break
    else:
        aru = False
    if aru:
        print((ans - 1))
    else:
        print(ans)


if __name__ == '__main__':
    main()
# Original solution
def main():
    H, W, M = (int(i) for i in input().split())
    hc = [0]*(H+1)
    wc = [0]*(W+1)
    maps = set()
    for _ in range(M):
        h, w = (int(i) for i in input().split())
        hc[h] += 1
        wc[w] += 1
        maps.add((h, w))
    mah = -1
    maw = -1
    hmaps = set()
    wmaps = set()
    for i, h in enumerate(hc):
        if mah < h:
            mah = h
            hmaps = {i}
        elif mah == h:
            hmaps.add(i)
    for i, w in enumerate(wc):
        if maw < w:
            maw = w
            wmaps = {i}
        elif maw == w:
            wmaps.add(i)
    ans = mah+maw
    aru = True

    for h in hmaps:
        for w in wmaps:
            if (h, w) not in maps:
                aru = False
                break
        if not aru:
            break
    if aru:
        print((ans - 1))
    else:
        print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    H, W, M = (int(i) for i in input().split())
    hc = [0]*(H+1)
    wc = [0]*(W+1)
    maps = set()
    for _ in range(M):
        h, w = (int(i) for i in input().split())
        hc[h] += 1
        wc[w] += 1
        maps.add((h, w))
    mah = max(hc)
    maw = max(wc)
    ans = mah+maw
    hmaps = []
    wmaps = []
    for i, h in enumerate(hc):
        if mah == h:
            hmaps.append(i)
    for i, w in enumerate(wc):
        if maw == w:
            wmaps.append(i)

    if M < len(hmaps) * len(wmaps):
        # 爆破対象の合計が最大になるマスがM個より多ければ，
        # 必ず爆破対象がないマスに爆弾を置くことができる
        # 逆にM個以下なら3*10^5のループにしかならないので
        # このようにif文で分けなくても，必ずO(M)になるのでelse節のforを回してよい
        print(ans)
    else:
        for h in hmaps:
            for w in wmaps:
                if (h, w) not in maps:
                    print(ans)
                    return
        else:
            print((ans-1))


if __name__ == '__main__':
    main()
# Original solution
def main():
    h, w, m = list(map(int, input().split()))
    bombs_h = [0] * h
    bombs_w = [0] * w
    B = []
    for n in range(m):
        h1, w1 = list(map(int, input().split()))
        B.append((h1-1, w1-1))
        bombs_w[w1-1] += 1
        bombs_h[h1-1] += 1
    h_maxindex = [i for i, x in enumerate(bombs_h) if x == max(bombs_h)]
    w_maxindex = [i for i, x in enumerate(bombs_w) if x == max(bombs_w)]
    max_h = max(bombs_h)
    max_w = max(bombs_w)
    cnt = 0
    k = len(h_maxindex) * len(w_maxindex)
    for i, j in B:
        if bombs_h[i] == max_h and bombs_w[j] == max_w:
            cnt += 1
    ans = max_h + max_w - (cnt == k)
    print(ans)
    
    
if __name__ == "__main__":
    main()

# Optimized solution
def main():
    h, w, m = list(map(int, input().split()))
    bombs_h = [0] * h
    bombs_w = [0] * w
    B = []
    for n in range(m):
        h1, w1 = [int(x)-1 for x in input().split()]
        B.append((h1, w1))
        bombs_w[w1] += 1
        bombs_h[h1] += 1
    max_h = max(bombs_h)
    max_w = max(bombs_w)
    h_maxindex = [i for i, x in enumerate(bombs_h) if x == max_h]
    w_maxindex = [i for i, x in enumerate(bombs_w) if x == max_w]
    cnt = 0
    k = len(h_maxindex) * len(w_maxindex)
    for i, j in B:
        if bombs_h[i] == max_h and bombs_w[j] == max_w:
            cnt += 1
    ans = max_h + max_w - (cnt == k)
    print(ans)
    
    
if __name__ == "__main__":
    main()
# Original solution
h,w,m = list(map(int,input().split()))
hw = [list(map(int,input().split())) for _ in range(m)]

hc = [0]*h
wc = [0]*w
d={}
for _h, _w in hw:
    hc[_h-1]+=1
    wc[_w-1]+=1
    d[(_h-1,_w-1)]=1
    
maxh = max(hc)
maxw = max(wc)
    
hoge = True
wi = [i for i in range(w) if wc[i]==maxw]
for h in [i for i in range(h) if hc[i]==maxh]:
    for w in wi:
        if (h,w) not in d:
            hoge=False
            
if hoge:
    print((maxh+maxw-1))
else:
    print((maxh+maxw))

# Optimized solution
h,w,m = list(map(int,input().split()))
hw = [list(map(int,input().split())) for _ in range(m)]

hc = [0]*h
wc = [0]*w
d={}
for _h, _w in hw:
    hc[_h-1]+=1
    wc[_w-1]+=1
    d[(_h-1,_w-1)]=1
    
maxh = max(hc)
maxw = max(wc)
    
        
hoge = True
wi = [i for i in range(w) if wc[i]==maxw]
for h in [i for i in range(h) if hc[i]==maxh]:
    for w in wi:
        if (h,w) not in d:
            hoge=False
            break
            
if hoge:
    print((maxh+maxw-1))
else:
    print((maxh+maxw))
# Original solution
H, W, M = [int(v) for v in input().split()]

targets = []

for _ in range(M):
    targets.append([int(v) for v in input().split()])

grid = []
for _ in range(H):
    grid.append([0] * W)

for x, y in targets:
    for i in range(H):
        grid[i][y-1] += 1
    
    for j in range(W):
        grid[x-1][j] += 1

    grid[x-1][y-1] -= 1

max_val = max(list([max(x) for x in grid]))

print(max_val)

# Optimized solution
H, W, M = [int(v) for v in input().split()]

targets = []

for _ in range(M):
    targets.append([int(v) - 1 for v in input().split()])

h_count = [0] * H
w_count = [0] * W

for x, y in targets:
    h_count[x] += 1
    w_count[y] += 1

h_count_max = max(h_count)

max_val = -1

for i in range(H):
    if h_count_max == h_count[i]:
        w_tmp = w_count.copy()

        for x, y in targets:
            if x == i:
                w_tmp[y] -= 1
        
        max_val = max(max_val, max(w_tmp) + h_count_max)

print(max_val)
# Original solution
import sys

def resolve(in_):
    H, W, M = list(map(int, next(in_).split()))
    targets = tuple(tuple(map(int, line.split())) for line in in_)
    # H, W, M = 3, 3, 3
    # targets = ((1, 1), (2, 1), (1, 3))
    
    target_h = {}
    target_w = {}
    target_hw = set()
    for h, w in targets:
        target_h[h - 1] = target_h.setdefault(h - 1, 0) + 1
        target_w[w - 1] = target_w.setdefault(w - 1, 0) + 1
        target_hw.add((h - 1, w - 1))

    ans = 0
    for h, a in list(target_h.items()):
        for w, b in list(target_w.items()):
            ans = max(ans, target_h[h] + target_w[w] - (1 if (h, w) in target_hw else 0))
    
    return ans

def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()


# Optimized solution
import sys
import itertools


def resolve(in_):
    H, W, M = list(map(int, next(in_).split()))
    targets = tuple(tuple(map(int, line.split())) for line in in_)
    
    target_h = {}
    target_w = {}
    target_hw = set()
    for h, w in targets:
        target_h[h] = target_h.setdefault(h, 0) + 1
        target_w[w] = target_w.setdefault(w, 0) + 1
        target_hw.add((h, w))

    max_h = max(target_h.values())
    max_w = max(target_w.values())

    h_set = {h for h, v in list(target_h.items()) if max_h == v}
    w_set = {w for w, v in list(target_w.items()) if max_w == v}

    ans = max_h + max_w - 1
    for hw in itertools.product(h_set, w_set):
        if hw not in target_hw:
            ans += 1
            break
    
    return ans


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()
# Original solution
H, W, M = list(map(int, input().split()))
targets = [list(map(int, input().split())) for _ in range(M)]
x_counter = [0 for _ in range(W + 1)]
y_counter = [0 for _ in range(H + 1)]
y_index = []
x_index = []
check = 0

for i in range(M):
    x, y = targets[i]
    y_counter[x] += 1
    x_counter[y] += 1

y_max, x_max = max(y_counter), max(x_counter)

for i in range(H + 1):
    if y_counter[i] == y_max:
        y_index.append(i)

for j in range(W + 1):
    if x_counter[j] == x_max:
        x_index.append(j)
check = len(y_index) * len(x_index)
for k in range(M):
    r, c = targets[k]
    if r in y_index and c in x_index:
        check -= 1

print((y_max + x_max if check > 0 else y_max + x_max -1))


# Optimized solution
h,w,m=list(map(int,input().split()))
item=[list(map(int,input().split())) for i in range(m)]
row=[0]*h
col=[0]*w
for i in range(m):
    x,y=item[i]
    row[x-1]+=1
    col[y-1]+=1
mr,mc=max(row),max(col)
xr=set([i for i in range(h) if row[i]==mr])
xc=set([i for i in range(w) if col[i]==mc])
check=len(xr)*len(xc)
for i in range(m):
    r,c=item[i]
    if r-1 in xr and c-1 in xc:
        check-=1
print((mr+mc if check>0 else mr+mc-1))
# Original solution
import sys
from collections import Counter


def main():
    input = sys.stdin.buffer.readline
    h, w, m = list(map(int, input().split()))
    h = [0] * m
    w = [0] * m
    object_set = set()
    for i in range(m):
        h[i], w[i] = list(map(int, input().split()))
        object_set.add((h[i], w[i]))
    h_counter = Counter(h)
    w_counter = Counter(w)
    max_h_num = h_counter.most_common()[0][1]
    max_w_num = w_counter.most_common()[0][1]
    ans = max_h_num + max_w_num

    h_cand = []
    w_cand = []
    for e, n in h_counter.most_common():
        if n == max_h_num:
            h_cand.append(e)
    for e, n in w_counter.most_common():
        if n == max_w_num:
            w_cand.append(e)

    ok = False
    for h_e in h_cand:
        for w_e in w_cand:
            if (h_e, w_e) not in object_set:
                ok = True

    print((ans if ok else ans - 1))


if __name__ == "__main__":
    main()


# Optimized solution
import sys
from collections import Counter


def main():
    input = sys.stdin.buffer.readline
    h, w, m = list(map(int, input().split()))
    h = [0] * m
    w = [0] * m
    object_set = set()
    for i in range(m):
        h[i], w[i] = list(map(int, input().split()))
        object_set.add((h[i], w[i]))
    h_counter = Counter(h)
    w_counter = Counter(w)
    max_h_num = h_counter.most_common()[0][1]
    max_w_num = w_counter.most_common()[0][1]
    ans = max_h_num + max_w_num

    h_cand = set()
    w_cand = set()
    for e, n in h_counter.most_common():
        if n == max_h_num:
            h_cand.add(e)
    for e, n in w_counter.most_common():
        if n == max_w_num:
            w_cand.add(e)

    cnt = 0
    for h_e, w_e in object_set:
        if h_e in h_cand and w_e in w_cand:
            cnt += 1

    print((ans if cnt < len(h_cand) * len(w_cand) else ans - 1))


if __name__ == "__main__":
    main()
# Original solution
from collections import defaultdict as dd
h, w, m = list(map(int, input().split()))

#dic[row, col] -> set(ids)
h_dic = dd(set)
w_dic = dd(set)
spot = set()

for i in range(m):
    h_c, w_c = list(map(int, input().split()))
    h_dic[h_c].add(i)
    w_dic[w_c].add(i)
    spot.add((h_c, w_c))
#print(h_dic, w_dic)

#H_lis -> [i, num_spot(int)]
max_h_num = 0
H_lis = []
for key, val in list(h_dic.items()):
    H_lis.append([key, len(val)])
    max_h_num = max(max_h_num, len(val))
max_w_num = 0
W_lis = []
for key, val in list(w_dic.items()):
    W_lis.append([key, len(val)])
    max_w_num = max(max_w_num, len(val))


#print(H_lis, W_lis)
#print(max_h)

ans = 0
max_h_lis = [val[0] for val in H_lis if val[1] == max_h_num]
max_w_lis = [val[0] for val in W_lis if val[1] == max_w_num]
for i in max_h_lis:
    for j in max_w_lis:
        count = max_h_num + max_w_num
        if (i, j) in spot:
            count -= 1
        ans = max(ans, count)
print(ans)

"""    
max_counter = 0
for i in h_dic.keys():
    for j in w_dic.keys():
        counter = len(h_dic[i] | w_dic[j])
        #print(i, j, h_dic[i] | w_dic[j],counter)
        max_counter = max(max_counter, counter)
print(max_counter)

"""

# Optimized solution
from sys import exit
from collections import defaultdict as dd
h, w, m = list(map(int, input().split()))

#dic[row, col] -> set(ids)
h_dic = dd(int)
w_dic = dd(int)
spot = set()

for i in range(m):
    h_c, w_c = list(map(int, input().split()))
    h_dic[h_c] += 1
    w_dic[w_c] += 1
    spot.add((h_c, w_c))
#print(h_dic, w_dic)

#H_lis -> [i, num_spot(int)]
max_h_num = 0
for key, val in list(h_dic.items()):
    max_h_num = max(max_h_num, val)
max_w_num = 0
W_lis = []
for key, val in list(w_dic.items()):
    max_w_num = max(max_w_num, val)


#print(H_lis, W_lis)
#print(max_h)

ans = 0
max_h_lis = [key for key in h_dic if h_dic[key] == max_h_num]
max_w_lis = [key for key in w_dic if w_dic[key] == max_w_num]
for i in max_h_lis:
    for j in max_w_lis:
        if (i, j) not in spot:
            print((max_h_num + max_w_num))
            exit()
else:
    print((max_h_num + max_w_num - 1))

"""    
max_counter = 0
for i in h_dic.keys():
    for j in w_dic.keys():
        counter = len(h_dic[i] | w_dic[j])
        #print(i, j, h_dic[i] | w_dic[j],counter)
        max_counter = max(max_counter, counter)
print(max_counter)

"""
# Original solution
# -*- coding: utf-8 -*-
# E

import sys
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

H, W, M = list(map(int, input().split()))
h = [] * M
w = [] * M
dic_combi = defaultdict(int)

for _ in range(M):
    h_, w_ = list(map(int, input().split()))
    h.append(h_)
    w.append(w_)
    dic_combi[h_ * (10**6) +  w_]=1

dic_h = Counter(h)
dic_w = Counter(w)
# print(dic_h, dic_w)
max_h_key = max(list(dic_h.items()), key=lambda x:x[1])[0]
max_w_key = max(list(dic_w.items()), key=lambda x:x[1])[0]

max_h = dic_h[max_h_key]
max_w = dic_w[max_w_key]

keys_h = [k for k, v in list(dic_h.items()) if v == max_h]
keys_w = [k for k, v in list(dic_w.items()) if v == max_w]


def get_num(ind_h, ind_w):
    ret = 0
    for i in range(M):
        if h[i] == ind_h or w[i] == ind_w:
           ret += 1
    return ret


ans = 0
for ind_h in keys_h:
    for ind_w in keys_w:
        # ret = get_num(ind_h, ind_w)
        ret = max_h + max_w
        if dic_combi[ind_h*(10**6) + ind_w] == 1:
            ret -= 1
        ans = max(ans, ret)

print(ans)






# Optimized solution
# -*- coding: utf-8 -*-
# E

import sys
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

H, W, M = list(map(int, input().split()))
h = [] * M
w = [] * M
dic_combi = defaultdict(int)

for _ in range(M):
    h_, w_ = list(map(int, input().split()))
    h.append(h_)
    w.append(w_)
    dic_combi[h_ * (10**6) +  w_]=1

dic_h = Counter(h)
dic_w = Counter(w)
# print(dic_h, dic_w)
max_h_key = max(list(dic_h.items()), key=lambda x:x[1])[0]
max_w_key = max(list(dic_w.items()), key=lambda x:x[1])[0]

max_h = dic_h[max_h_key]
max_w = dic_w[max_w_key]

keys_h = [k for k, v in list(dic_h.items()) if v == max_h]
keys_w = [k for k, v in list(dic_w.items()) if v == max_w]


ans = 0
for ind_h in keys_h:
    for ind_w in keys_w:
        ret = max_h + max_w
        if dic_combi[ind_h*(10**6) + ind_w] == 1:
            ret -= 1
        else:
            print(ret)
            sys.exit()
        ans = max(ans, ret)

print(ans)