h, w, m = list(map(int, input().split()))



target = set()

rows = [0] * h

cols = [0] * w

for i in range(m):

    y, x = [int(x) - 1 for x in input().split()]

    rows[y] += 1

    cols[x] += 1

    target.add((y, x))



rows_sorted = [(a, i) for i, a in enumerate(rows)]

rows_sorted.sort(reverse=True)

cols_sorted = [(a, i) for i, a in enumerate(cols)]

cols_sorted.sort(reverse=True)



max_r = rows_sorted[0][0]

max_c = cols_sorted[0][0]



i = 0

max_val = max(max_r, max_c)

while i < h and rows_sorted[i][0] == max_r:

    j = 0

    while j < w and cols_sorted[j][0] == max_c:

        val = rows_sorted[i][0] + cols_sorted[j][0]

        if (rows_sorted[i][1], cols_sorted[j][1]) in target:

            val -= 1

        else:

            max_val = val

            break

        max_val = max(max_val, val)

        j += 1

    i += 1

print(max_val)

h, w, m = list(map(int, input().split()))



target_pos = set()

target_n_row = [0] * h

target_n_col = [0] * w

for i in range(m):

    y, x = [int(x) - 1 for x in input().split()]

    target_n_row[y] += 1

    target_n_col[x] += 1

    target_pos.add((y, x))



sorted_row = [(a, i) for i, a in enumerate(target_n_row)]

sorted_row.sort(reverse=True)

sorted_col = [(a, i) for i, a in enumerate(target_n_col)]

sorted_col.sort(reverse=True)



max_r = sorted_row[0][0]

max_c = sorted_col[0][0]



i = 0

max_val = max_r + max_c - 1

while i < h and sorted_row[i][0] == max_r:

    j = 0

    while j < w and sorted_col[j][0] == max_c:

        if not (sorted_row[i][1], sorted_col[j][1]) in target_pos:

            max_val = sorted_row[i][0] + sorted_col[j][0]

            break

        j += 1

    i += 1

print(max_val)

h, w, m = list(map(int, input().split()))
target = set()
rows = [0] * h
cols = [0] * w
for i in range(m):
    y, x = [int(x) - 1 for x in input().split()]
    rows[y] += 1
    cols[x] += 1
    target.add((y, x))
rows_sorted = [(a, i) for i, a in enumerate(rows)]
rows_sorted.sort(reverse=True)
cols_sorted = [(a, i) for i, a in enumerate(cols)]
cols_sorted.sort(reverse=True)
max_r = rows_sorted[0][0]
max_c = cols_sorted[0][0]
i = 0
max_val = max(max_r, max_c)
while i < h and rows_sorted[i][0] == max_r:
    j = 0
    while j < w and cols_sorted[j][0] == max_c:
        val = rows_sorted[i][0] + cols_sorted[j][0]
        if (rows_sorted[i][1], cols_sorted[j][1]) in target:
            val -= 1
        else:
            max_val = val
            break
        max_val = max(max_val, val)
        j += 1
    i += 1
print(max_val)

h, w, m = list(map(int, input().split()))
target_pos = set()
target_n_row = [0] * h
target_n_col = [0] * w
for i in range(m):
    y, x = [int(x) - 1 for x in input().split()]
    target_n_row[y] += 1
    target_n_col[x] += 1
    target_pos.add((y, x))
sorted_row = [(a, i) for i, a in enumerate(target_n_row)]
sorted_row.sort(reverse=True)
sorted_col = [(a, i) for i, a in enumerate(target_n_col)]
sorted_col.sort(reverse=True)
max_r = sorted_row[0][0]
max_c = sorted_col[0][0]
i = 0
max_val = max_r + max_c - 1
while i < h and sorted_row[i][0] == max_r:
    j = 0
    while j < w and sorted_col[j][0] == max_c:
        if not (sorted_row[i][1], sorted_col[j][1]) in target_pos:
            max_val = sorted_row[i][0] + sorted_col[j][0]
            break
        j += 1
    i += 1
print(max_val)

-target = set() -rows = [0] * h -cols = [0] * w +target_pos = set() +target_n_row = [0] * h +target_n_col = [0] * w -    rows[y] += 1 -    cols[x] += 1 -    target.add((y, x)) -rows_sorted = [(a, i) for i, a in enumerate(rows)] -rows_sorted.sort(reverse=True) -cols_sorted = [(a, i) for i, a in enumerate(cols)] -cols_sorted.sort(reverse=True) -max_r = rows_sorted[0][0] -max_c = cols_sorted[0][0] +    target_n_row[y] += 1 +    target_n_col[x] += 1 +    target_pos.add((y, x)) +sorted_row = [(a, i) for i, a in enumerate(target_n_row)] +sorted_row.sort(reverse=True) +sorted_col = [(a, i) for i, a in enumerate(target_n_col)] +sorted_col.sort(reverse=True) +max_r = sorted_row[0][0] +max_c = sorted_col[0][0] -max_val = max(max_r, max_c) -while i < h and rows_sorted[i][0] == max_r: +max_val = max_r + max_c - 1 +while i < h and sorted_row[i][0] == max_r: -    while j < w and cols_sorted[j][0] == max_c: -        val = rows_sorted[i][0] + cols_sorted[j][0] -        if (rows_sorted[i][1], cols_sorted[j][1]) in target: -            val -= 1 -        else: -            max_val = val +    while j < w and sorted_col[j][0] == max_c: +        if not (sorted_row[i][1], sorted_col[j][1]) in target_pos: +            max_val = sorted_row[i][0] + sorted_col[j][0] -        max_val = max(max_val, val)