H, W, M = map(int,input().split())
ARR = []

for i in range(M):
    ARR.append(list(map(int,input().split())))

def calculate(h, w, m, arr):
    points = set()



    rowSum = [0 for i in range(h)]
    columnSum = [0 for i in range(w)]

    for ar in arr:
        points.add((ar[0]-1, ar[1]-1))
        rowSum[ar[0]-1] += 1
        columnSum[ar[1]-1] += 1

    maxRowSum = max(rowSum)
    maxColumnSum = max(columnSum)


    a0 = []

    for i in range(len(rowSum)):
        if rowSum[i] == maxRowSum:
            a0.append(i)

    a1 = []
    for i in range(len(columnSum)):
        if columnSum[i] == maxColumnSum:
            a1.append(i)

    result = 0
    for hIndex in a0:
        for wIndex in a1:

            if (hIndex,wIndex) in points:
                result = max(result, maxRowSum + maxColumnSum - 1)
            else:
                result = max(result, maxRowSum + maxColumnSum)
                print(result)
                exit()

    print(result)


calculate(H, W, M, ARR) H, W, M = map(int,input().split()) H map(int,input().split()) map int input().split() ().split () input split W M ARR = [] ARR [] for i in range(M):
    ARR.append(list(map(int,input().split()))) i range(M) range M ARR.append(list(map(int,input().split()))) ARR.append ARR append list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split def calculate(h, w, m, arr):
    points = set()



    rowSum = [0 for i in range(h)]
    columnSum = [0 for i in range(w)]

    for ar in arr:
        points.add((ar[0]-1, ar[1]-1))
        rowSum[ar[0]-1] += 1
        columnSum[ar[1]-1] += 1

    maxRowSum = max(rowSum)
    maxColumnSum = max(columnSum)


    a0 = []

    for i in range(len(rowSum)):
        if rowSum[i] == maxRowSum:
            a0.append(i)

    a1 = []
    for i in range(len(columnSum)):
        if columnSum[i] == maxColumnSum:
            a1.append(i)

    result = 0
    for hIndex in a0:
        for wIndex in a1:

            if (hIndex,wIndex) in points:
                result = max(result, maxRowSum + maxColumnSum - 1)
            else:
                result = max(result, maxRowSum + maxColumnSum)
                print(result)
                exit()

    print(result) calculate points = set() points set() set 0 for i in range(h) for i in range(h) i range(h) range h for i in range(h) 0 rowSum = [0 for i in range(h)] rowSum [0 for i in range(h)] 0 for i in range(w) for i in range(w) i range(w) range w for i in range(w) 0 columnSum = [0 for i in range(w)] columnSum [0 for i in range(w)] for ar in arr:
        points.add((ar[0]-1, ar[1]-1))
        rowSum[ar[0]-1] += 1
        columnSum[ar[1]-1] += 1

     ar arr points.add((ar[0]-1, ar[1]-1)) points.add points add (ar[0]-1, ar[1]-1) ar[0]-1 ar[0] ar 0 1 ar[1]-1 ar[1] ar 1 1 rowSum[ar[0]-1] += 1 rowSum[ar[0]-1] rowSum ar[0]-1 ar[0] ar 0 1 1 columnSum[ar[1]-1] += 1 columnSum[ar[1]-1] columnSum ar[1]-1 ar[1] ar 1 1 1 maxRowSum = max(rowSum) maxRowSum max(rowSum) max rowSum maxColumnSum = max(columnSum) maxColumnSum max(columnSum) max columnSum a0 = [] a0 [] for i in range(len(rowSum)):
        if rowSum[i] == maxRowSum:
            a0.append(i)

     i range(len(rowSum)) range len(rowSum) len rowSum if rowSum[i] == maxRowSum:
            a0.append(i)

     rowSum[i] == maxRowSum rowSum[i] rowSum i maxRowSum a0.append(i) a0.append a0 append i a1 = [] a1 [] for i in range(len(columnSum)):
        if columnSum[i] == maxColumnSum:
            a1.append(i)

     i range(len(columnSum)) range len(columnSum) len columnSum if columnSum[i] == maxColumnSum:
            a1.append(i)

     columnSum[i] == maxColumnSum columnSum[i] columnSum i maxColumnSum a1.append(i) a1.append a1 append i result = 0 result 0 for hIndex in a0:
        for wIndex in a1:

            if (hIndex,wIndex) in points:
                result = max(result, maxRowSum + maxColumnSum - 1)
            else:
                result = max(result, maxRowSum + maxColumnSum)
                print(result)
                exit()

     hIndex a0 for wIndex in a1:

            if (hIndex,wIndex) in points:
                result = max(result, maxRowSum + maxColumnSum - 1)
            else:
                result = max(result, maxRowSum + maxColumnSum)
                print(result)
                exit()

     wIndex a1 if (hIndex,wIndex) in points:
                result = max(result, maxRowSum + maxColumnSum - 1)
            else:
                result = max(result, maxRowSum + maxColumnSum)
                print(result)
                exit()

     (hIndex,wIndex) in points (hIndex,wIndex) hIndex wIndex points result = max(result, maxRowSum + maxColumnSum - 1) result max(result, maxRowSum + maxColumnSum - 1) max result maxRowSum + maxColumnSum - 1 maxRowSum + maxColumnSum maxRowSum maxColumnSum 1 result = max(result, maxRowSum + maxColumnSum) result max(result, maxRowSum + maxColumnSum) max result maxRowSum + maxColumnSum maxRowSum maxColumnSum print(result) print result exit() exit print(result) print result h h w w m m arr arr calculate(H, W, M, ARR) calculate H W M ARR def calculate(h, w, m, arr):
    points = set()



    rowSum = [0 for i in range(h)]
    columnSum = [0 for i in range(w)]

    for ar in arr:
        points.add((ar[0]-1, ar[1]-1))
        rowSum[ar[0]-1] += 1
        columnSum[ar[1]-1] += 1

    maxRowSum = max(rowSum)
    maxColumnSum = max(columnSum)


    a0 = []

    for i in range(len(rowSum)):
        if rowSum[i] == maxRowSum:
            a0.append(i)

    a1 = []
    for i in range(len(columnSum)):
        if columnSum[i] == maxColumnSum:
            a1.append(i)

    result = 0
    for hIndex in a0:
        for wIndex in a1:

            if (hIndex,wIndex) in points:
                result = max(result, maxRowSum + maxColumnSum - 1)
            else:
                result = max(result, maxRowSum + maxColumnSum)
                print(result)
                exit()

    print(result) def calculate(h, w, m, arr):
    points = set()



    rowSum = [0 for i in range(h)]
    columnSum = [0 for i in range(w)]

    for ar in arr:
        points.add((ar[0]-1, ar[1]-1))
        rowSum[ar[0]-1] += 1
        columnSum[ar[1]-1] += 1

    maxRowSum = max(rowSum)
    maxColumnSum = max(columnSum)


    a0 = []

    for i in range(len(rowSum)):
        if rowSum[i] == maxRowSum:
            a0.append(i)

    a1 = []
    for i in range(len(columnSum)):
        if columnSum[i] == maxColumnSum:
            a1.append(i)

    result = 0
    for hIndex in a0:
        for wIndex in a1:

            if (hIndex,wIndex) in points:
                result = max(result, maxRowSum + maxColumnSum - 1)
            else:
                result = max(result, maxRowSum + maxColumnSum)
                print(result)
                exit()

    print(result) calculate W, M = map(int,input().split()) map(int,input().split()) W H, W, M = map(int,input().split()) map(int,input().split()) H ARR = [] [] ARR M = map(int,input().split()) map(int,input().split()) M
H, W, M = map(int,input().split())
ARR = []

for i in range(M):
    ARR.append(list(map(int,input().split())))

def calculate(h, w, m, arr):
    points = set()



    rowSum = [0 for i in range(h)]
    columnSum = [0 for i in range(w)]

    for ar in arr:
        points.add((ar[0]-1, ar[1]-1))
        rowSum[ar[0]-1] += 1
        columnSum[ar[1]-1] += 1

    maxRowSum = max(rowSum)
    maxColumnSum = max(columnSum)


    a0 = []

    for i in range(len(rowSum)):
        if rowSum[i] == maxRowSum:
            a0.append(i)

    a1 = []
    for i in range(len(columnSum)):
        if columnSum[i] == maxColumnSum:
            a1.append(i)

    result = 0
    for hIndex in a0:
        for wIndex in a1:

            if (hIndex,wIndex) in points:
                result = max(result, maxRowSum + maxColumnSum - 1)
            else:
                result = max(result, maxRowSum + maxColumnSum)
                print(result)
                exit()

    print(result)


calculate(H, W, M, ARR)
