-----Problem Statement-----
You all must have played the game candy crush. So here is a bomb which works much the fruit bomb in candy crush. A designer, Anton, designed a very powerful bomb. The bomb, when placed on a location $(x, y)$ in a $R \times C$ grid, wipes out the row $x$ and column $y$ completely.
You are given a $R\times C$ grid with $N$ targets. You have only one bomb. Your aim is to maximize the damage and hence destroy most number of targets. Given the location of targets on the grid, find out the number of targets that can destroyed.
The grid system uses index starting with $0$.

-----Input-----
- First line contains three space separated integers, $R$, $C$ and $N$. Then, $N$ lines follow.
- Each line contains space separated integers $r$ and $c$ mentioning the location of the target.

-----Output-----
A single integer giving the number of targets that can be destroyed.

-----Constraints-----
- $1 \leq R, C \leq 3 \times 10^5$
- $1 \leq N \leq min(R \times C,  3 \times 10^5)$
- $0 \leq r < R$
- $0 \leq c < C$
- Any input pair $(r, c)$ is not repeated.

-----Subtasks-----
The total marks will be divided into:
- 20% : $R, C \leq 10^3$
- 80% : Original Constraints

-----Sample Input-----
2 3 3
1 1
0 0
0 2

-----Sample Output-----
3

-----EXPLANATION-----
It is possible to destroy all the targets if we place the bomb at $(0, 1)$. Hence, total number of targets destroyed is $3$, which is our answer.

Difficulty: UNKNOWN_DIFFICULTY

Solutions:
(r, c, n) = map(int, input().split())
coordinates = []
(coordinates_1, coordinates_2) = ({}, {})
for _ in range(n):
	(x, y) = map(int, input().split())
	coordinates.append([x, y])
for i in coordinates:
	if i[0] in coordinates_1:
		coordinates_1[i[0]] += 1
	else:
		coordinates_1[i[0]] = 1
	if i[1] in coordinates_2:
		coordinates_2[i[1]] += 1
	else:
		coordinates_2[i[1]] = 1
print(max(coordinates_1.values()) + max(coordinates_2.values()))


try:
	(r, c, n) = list(map(int, input().split()))
	grid = [[0 for j in range(c)] for i in range(r)]
	for i in range(n):
		(a, b) = list(map(int, input().split()))
		grid[a][b] = 1
	sumcol = [sum(x) for x in zip(*grid)]
	sumrow = []
	for i in grid:
		sumrow.append(sum(i))
	print(max(sumrow) + max(sumcol))
except EOFError:
	pass


from collections import defaultdict
(r, c, n) = (int(i) for i in input().split())
dr = defaultdict(int)
dc = defaultdict(int)
for i in range(n):
	(x, y) = (int(i) for i in input().split())
	dr[x] += 1
	dc[y] += 1
mr = max(dr.values())
mc = max(dc.values())
if 1 not in [r, c]:
	print(mr + mc)
else:
	print(max(mr, mc))


(r, c, n) = map(int, input().split())
ar = []
for i in range(n):
	ar.append(list(map(int, input().split())))
d1 = {}
for i in ar:
	try:
		d1[i[0]] += 1
	except:
		d1[i[0]] = 1
maxi = -1
for i in d1:
	if d1[i] > maxi:
		maxi = d1[i]
		res1 = i
d2 = {}
for i in ar:
	if i[0] != res1:
		try:
			d2[i[1]] += 1
		except:
			d2[i[1]] = 1
maxi = -1
for i in d2:
	if d2[i] > maxi:
		maxi = d2[i]
		res2 = i
ans1 = d1[res1] + d2[res2]
d1 = {}
for i in ar:
	try:
		d1[i[1]] += 1
	except:
		d1[i[1]] = 1
maxi = -1
for i in d1:
	if d1[i] > maxi:
		maxi = d1[i]
		res1 = i
d2 = {}
for i in ar:
	if i[1] != res1:
		try:
			d2[i[0]] += 1
		except:
			d2[i[0]] = 1
maxi = -1
for i in d2:
	if d2[i] > maxi:
		maxi = d2[i]
		res2 = i
ans2 = d1[res1] + d2[res2]
print(max(ans1, ans2))


import sys
sys.setrecursionlimit(500005)
stdin = sys.stdin
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
ns = lambda : stdin.readline().strip()
(h, w, m) = na()
rs = [0] * h
cs = [0] * w
se = set()
for i in range(m):
	(r, c) = na()
	rs[r - 1] += 1
	cs[c - 1] += 1
	se.add((r - 1) * w + c - 1)
rmax = max(rs)
cmax = max(cs)
remax = rs.count(rmax)
cemax = cs.count(cmax)
if remax * cemax > m:
	print(rmax + cmax)
	return
rmaxs = [i for (i, _) in enumerate(rs) if _ == rmax]
cmaxs = [i for (i, _) in enumerate(cs) if _ == cmax]
for r in rmaxs:
	for c in cmaxs:
		if r * w + c not in se:
			print(rmax + cmax)
			return
print(rmax + cmax - 1)


(r, c, n) = list(map(int, input().split()))
a = set()
c2 = [0 for i in range(r)]
d2 = [0 for j in range(c)]
for i in range(n):
	(c1, d1) = list(map(int, input().split()))
	a.add((c1, d1))
	c2[c1] += 1
	d2[d1] += 1
mr = max(c2)
mc = max(d2)
p1 = []
p2 = []
for i in range(r):
	if c2[i] == mr:
		p1.append(i)
for j in range(c):
	if d2[j] == mc:
		p2.append(j)
ans = mr + mc
for i in p1:
	for j in p2:
		if (i, j) in a:
			continue
		print(ans)
		return
ans -= 1
print(ans)


(r, c, n) = map(int, input().split())
X = [0] * (r + 1)
Y = [0] * (c + 1)
for i in range(n):
	(x, y) = map(int, input().split())
	X[x] += 1
	Y[y] += 1
print(max(X) + max(Y))


(r, c, n) = map(int, input().split())
x = {}
y = {}
xy = {}
for i in range(n):
	a = [int(i) for i in input().split()]
	if x.get(a[0]) == None:
		x[a[0]] = 1
	else:
		x[a[0]] += 1
	if y.get(a[1]) == None:
		y[a[1]] = 1
	else:
		y[a[1]] += 1
	xy[tuple(a)] = 1
xmax = max(x, key=x.get)
ymax = max(y, key=y.get)
ar = []
ar.append(xmax)
ar.append(ymax)
count = x[xmax] + y[ymax]
if xy.get(tuple(ar)) != None:
	count -= 1
print(count)


(n, m, x) = list(map(int, input().split()))
arr = [[0 for i in range(m)] for j in range(n)]
dpr = [0] * n
dpc = [0] * m
for i in range(x):
	(a, b) = list(map(int, input().split()))
	arr[a][b] = 1
	dpr[a] += 1
	dpc[b] += 1
max = -1
for i in range(n):
	for j in range(m):
		sum = dpr[i] + dpc[j]
		if arr[i][j] == 1:
			sum -= 1
		if sum > max:
			max = sum
		if max == x:
			break
print(max)


(r, c, n) = map(int, input().split())
a = [[0 for i in range(c)] for j in range(r)]
for i in range(n):
	(c1, d1) = map(int, input().split())
	a[c1][d1] = 1
a2 = [[0 for i in range(r)] for j in range(c)]
for i in range(c):
	for j in range(r):
		a2[i][j] = a[j][i]
c2 = [0 for i in range(r)]
d2 = [0 for j in range(c)]
for i in range(r):
	c2[i] = sum(a[i])
for i in range(c):
	d2[i] = sum(a2[i])
ans = 0
for i in range(r):
	for j in range(c):
		if a[i][j] == 1:
			ans = max(ans, c2[i] + d2[j] - 1)
		else:
			ans = max(ans, c2[i] + d2[j])
print(ans)


def f(lst1, lst2):
	dict1 = {}.fromkeys(lst1, 0)
	for key in lst1:
		dict1[key] += 1
	s = max(dict1.values())
	for i in dict1:
		if dict1[i] == s:
			key = i
			break
	lst3 = []
	for (i, j) in zip(lst1, lst2):
		if i != key:
			lst3.append(j)
	dict2 = {}.fromkeys(lst3, 0)
	for key in lst3:
		dict2[key] += 1
	s1 = max(dict2.values())
	return s + s1
(r, c, n) = list(map(int, input().split()))
lst1 = []
lst2 = []
for i in range(n):
	(r, c) = list(map(int, input().split()))
	lst1.append(r)
	lst2.append(c)
print(max(f(lst1, lst2), f(lst2, lst1)))


(r, c, n) = list(map(int, input().split()))
ro = [0] * (r + 1)
co = [0] * (c + 1)
for i in range(n):
	(a, b) = list(map(int, input().split()))
	ro[a] += 1
	co[b] += 1
ma = 0
ma += max(ro)
ma += max(co)
print(ma)


from sys import stdin, stdout
(r, c, n) = map(int, stdin.readline().split())
fx = {}
fy = {}
s = set()
for _ in range(n):
	(x, y) = stdin.readline().split()
	fx[x] = fx.get(x, 0) + 1
	fy[y] = fy.get(y, 0) + 1
	s.add((x, y))
(xl, xn) = ([], max(fx.values()))
for x in fx:
	if fx[x] == xn:
		xl.append(x)
(yl, yn) = ([], max(fy.values()))
for y in fy:
	if fy[y] == yn:
		yl.append(y)
count = xn + yn - 1
broken = False
for x in xl:
	for y in yl:
		if (x, y) not in s:
			broken = True
			break
	if broken:
		break
stdout.write(str(count + broken))


import sys
import math
from collections import defaultdict, Counter
input = sys.stdin.readline

def print(x):
	sys.stdout.write(str(x) + '\n')
(r, c, n) = map(int, input().split())
row = [0] * r
col = [0] * c
s = set()
for i in range(n):
	(x, y) = map(int, input().split())
	row[x] += 1
	col[y] += 1
	s.add((x, y))
ans = 0
for i in range(r):
	for j in range(c):
		cur = row[i] + col[j]
		if (i, j) in s:
			cur -= 1
		ans = max(cur, ans)
print(ans)


(r, c, n) = list(map(int, input().split()))
ro = {}
col = {}
for i in range(n):
	(p, q) = list(map(int, input().split()))
	try:
		ro[p] += 1
	except KeyError:
		ro[p] = 1
	try:
		col[q] += 1
	except KeyError:
		col[q] = 1
(mr, mc) = (-1, -1)
(v1, v2) = (-1, -1)
for i in list(ro.keys()):
	if ro[i] > v1:
		v1 = ro[i]
		mr = i
for i in list(col.keys()):
	if col[i] > v2:
		v2 = col[i]
		mc = i
print(v1 + v2)