import collections, itertools

h, w, m = map(int, input().split())
bombs = set(tuple(map(int, input().split())) for _ in range(m))

a = collections.Counter(x for x, y in bombs)
b = collections.Counter(y for x, y in bombs)
a_max_val = max(a.values())
b_max_val = max(b.values())
a_max_list = [k for k, v in a.items() if v == a_max_val]
b_max_list = [k for k, v in b.items() if v == b_max_val]

for a_max, b_max in itertools.product(a_max_list, b_max_list):
    if not (a_max, b_max) in bombs:
        print(a_max_val + b_max_val)
        exit(0)

print(a_max_val + b_max_val - 1) import collections, itertools collections itertools h, w, m = map(int, input().split()) h map(int, input().split()) map int input().split() ().split () input split w m bombs = set(tuple(map(int, input().split())) for _ in range(m)) bombs set(tuple(map(int, input().split())) for _ in range(m)) set tuple(map(int, input().split())) tuple map(int, input().split()) map int input().split() ().split () input split a = collections.Counter(x for x, y in bombs) a collections.Counter(x for x, y in bombs) collections.Counter collections Counter x b = collections.Counter(y for x, y in bombs) b collections.Counter(y for x, y in bombs) collections.Counter collections Counter y a_max_val = max(a.values()) a_max_val max(a.values()) max a.values() a.values a values b_max_val = max(b.values()) b_max_val max(b.values()) max b.values() b.values b values k for k, v in a.items() if v == a_max_val for k, v in a.items() if v == a_max_val k v a.items() a.items a items v == a_max_val v a_max_val if v == a_max_val k a_max_list = [k for k, v in a.items() if v == a_max_val] a_max_list [k for k, v in a.items() if v == a_max_val] k for k, v in b.items() if v == b_max_val for k, v in b.items() if v == b_max_val k v b.items() b.items b items v == b_max_val v b_max_val if v == b_max_val k b_max_list = [k for k, v in b.items() if v == b_max_val] b_max_list [k for k, v in b.items() if v == b_max_val] for a_max, b_max in itertools.product(a_max_list, b_max_list):
    if not (a_max, b_max) in bombs:
        print(a_max_val + b_max_val)
        exit(0) a_max b_max itertools.product(a_max_list, b_max_list) itertools.product itertools product a_max_list b_max_list if not (a_max, b_max) in bombs:
        print(a_max_val + b_max_val)
        exit(0) not (a_max, b_max) in bombs (a_max, b_max) in bombs (a_max, b_max) a_max b_max bombs print(a_max_val + b_max_val) print a_max_val + b_max_val a_max_val b_max_val exit(0) exit 0 print(a_max_val + b_max_val - 1) print a_max_val + b_max_val - 1 a_max_val + b_max_val a_max_val b_max_val 1 w, m = map(int, input().split()) map(int, input().split()) w a_max_val = max(a.values()) max(a.values()) a_max_val b_max_list = [k for k, v in b.items() if v == b_max_val] [k for k, v in b.items() if v == b_max_val] b_max_list m = map(int, input().split()) map(int, input().split()) m bombs = set(tuple(map(int, input().split())) for _ in range(m)) set(tuple(map(int, input().split())) for _ in range(m)) bombs a_max_list = [k for k, v in a.items() if v == a_max_val] [k for k, v in a.items() if v == a_max_val] a_max_list a = collections.Counter(x for x, y in bombs) collections.Counter(x for x, y in bombs) a b = collections.Counter(y for x, y in bombs) collections.Counter(y for x, y in bombs) b b_max_val = max(b.values()) max(b.values()) b_max_val h, w, m = map(int, input().split()) map(int, input().split()) h
import collections, itertools

h, w, m = map(int, input().split())
bombs = set(tuple(map(int, input().split())) for _ in range(m))

a = collections.Counter(x for x, y in bombs)
b = collections.Counter(y for x, y in bombs)
a_max_val = max(a.values())
b_max_val = max(b.values())
a_max_list = [k for k, v in a.items() if v == a_max_val]
b_max_list = [k for k, v in b.items() if v == b_max_val]

for a_max, b_max in itertools.product(a_max_list, b_max_list):
    if not (a_max, b_max) in bombs:
        print(a_max_val + b_max_val)
        exit(0)

print(a_max_val + b_max_val - 1)