Inna loves sleeping very much, so she needs n alarm clocks in total to wake up. Let's suppose that Inna's room is a 100 × 100 square with the lower left corner at point (0, 0) and with the upper right corner at point (100, 100). Then the alarm clocks are points with integer coordinates in this square.

The morning has come. All n alarm clocks in Inna's room are ringing, so Inna wants to turn them off. For that Inna has come up with an amusing game:  First Inna chooses a type of segments that she will use throughout the game. The segments can be either vertical or horizontal.  Then Inna makes multiple moves. In a single move, Inna can paint a segment of any length on the plane, she chooses its type at the beginning of the game (either vertical or horizontal), then all alarm clocks that are on this segment switch off. The game ends when all the alarm clocks are switched off. 

Inna is very sleepy, so she wants to get through the alarm clocks as soon as possible. Help her, find the minimum number of moves in the game that she needs to turn off all the alarm clocks!


-----Input-----

The first line of the input contains integer n (1 ≤ n ≤ 10^5) — the number of the alarm clocks. The next n lines describe the clocks: the i-th line contains two integers x_{i}, y_{i} — the coordinates of the i-th alarm clock (0 ≤ x_{i}, y_{i} ≤ 100).

Note that a single point in the room can contain any number of alarm clocks and the alarm clocks can lie on the sides of the square that represents the room.


-----Output-----

In a single line print a single integer — the minimum number of segments Inna will have to draw if she acts optimally.


-----Examples-----
Input
4
0 0
0 1
0 2
1 0

Output
2

Input
4
0 0
0 1
1 0
1 1

Output
2

Input
4
1 1
1 2
2 3
3 3

Output
3



-----Note-----

In the first sample, Inna first chooses type "vertical segments", and then she makes segments with ends at : (0, 0), (0, 2); and, for example, (1, 0), (1, 1). If she paints horizontal segments, she will need at least 3 segments.

In the third sample it is important to note that Inna doesn't have the right to change the type of the segments during the game. That's why she will need 3 horizontal or 3 vertical segments to end the game.

Difficulty: MEDIUM
Tags: Implementation

Starter code:

Solutions:
num = int(input())
hor = []
ver = []
for i in range(num):
	inp = list(map(int, input().split()))
	hor.extend([inp[0]])
	ver.extend([inp[1]])
seth = set(hor)
setv = set(ver)
print(min(len(seth), len(setv)))


(hor, ver) = (set(), set())
for i in range(int(input())):
	(x, y) = map(int, input().split())
	hor.add(y)
	ver.add(x)
print(min(len(hor), len(ver)))


(SF, SS) = (set(), set())
for i in range(int(input())):
	Temp = list(map(int, input().split()))
	SF.add(Temp[0])
	SS.add(Temp[1])
print(min(len(SF), len(SS)))


n = int(input())
l = []
x = []
y = []
c1 = c2 = 0
for i in range(0, n):
	(p, q) = map(int, input().split())
	temp = []
	temp.append(p)
	temp.append(q)
	x.append(p)
	y.append(q)
	l.append(temp)
x.sort()
y.sort()
for i in range(len(x) - 1):
	if x[i] == x[i + 1] and i == len(x) - 2:
		c1 += 1
	elif x[i] == x[i + 1]:
		continue
	elif i == len(x) - 2 and x[i] != x[i + 1]:
		c1 += 2
	else:
		c1 += 1
for i in range(len(y) - 1):
	if y[i] == y[i + 1] and i == len(y) - 2:
		c2 += 1
	elif y[i] == y[i + 1]:
		continue
	elif i == len(y) - 2 and y[i] != y[i + 1]:
		c2 += 2
	else:
		c2 += 1
if len(x) == 1:
	c1 = c2 = 1
print(min(c1, c2))


def fun(x):
	d1 = set()
	d2 = set()
	while x:
		y = list(map(int, input().split()))
		d1.add(y[0])
		d2.add(y[1])
		x -= 1
	return min(len(d1), len(d2))
x = int(input())
print(fun(x))


I = input
a = set()
b = set()
for _ in '0' * int(I()):
	(x, y) = I().split()
	a.add(x)
	b.add(y)
print(min(len(a), len(b)))


def main():
	n = int(input())
	x = []
	y = []
	for _ in range(n):
		_input = list(map(int, input().split()))
		x.append(_input[0])
		y.append(_input[1])
	print(min(len(set(x)), len(set(y))))
main()


a = set()
b = set()
n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	a.add(x)
	b.add(y)
print(min(len(a), len(b)))


n = int(input())
h = set()
v = set()
for i in range(n):
	(a, b) = map(int, input().split(' '))
	h.add(a)
	v.add(b)
print(min(len(h), len(v)))


import math
import cmath
n = int(input())
a = set()
b = set()
for _ in range(n):
	(u, v) = map(int, input().split())
	a.add(u)
	b.add(v)
print(min(len(a), len(b)))


from sys import stdin, stdout
a = [0] * 101
b = [0] * 101
n = int(stdin.readline())
for i in range(n):
	(x, y) = list(map(int, stdin.readline().split()))
	if a[x] == 0:
		a[x] = 1
	if b[y] == 0:
		b[y] = 1
stdout.write(str(min(sum(a), sum(b))))


n = int(input())
x = [True for i in range(102)]
y = [True for i in range(102)]
cntx = 0
cnty = 0
for i in range(n):
	(a, b) = [int(j) for j in input().split()]
	if x[a]:
		x[a] = False
		cntx += 1
	if y[b]:
		y[b] = False
		cnty += 1
print(min(cntx, cnty))


set_x = set()
set_y = set()
n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	set_x.add(x)
	set_y.add(y)
print(min(len(set_x), len(set_y)))


n = int(input())
set1 = set()
set2 = set()
for i in range(n):
	(x, y) = map(int, input().split())
	set1.add(x)
	set2.add(y)
p = min(len(set1), len(set2))
print(p)


from collections import Counter
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
x = []
y = []
for i in range(n):
	(n, k) = map(int, input().split())
	x.append(n)
	y.append(k)
print(min(len(list(set(x))), len(list(set(y)))))


i = lambda : map(int, input().split())
(n,) = i()
(a1, a2) = ([], [])
for _ in range(n):
	(x, y) = i()
	a1.append(x)
	a2.append(y)
print(min(len(set(a1)), len(set(a2))))


n = int(input())
x = set()
y = set()
for i in range(n):
	(x1, y1) = list(map(int, input().split(' ')))
	x.add(x1)
	y.add(y1)
print(min(len(x), len(y)))


n = int(input())
xcor = []
ycor = []
for i in range(n):
	(x, y) = map(int, input().split())
	xcor.append(x)
	ycor.append(y)
a = len(set(xcor))
b = len(set(ycor))
print(min(a, b))


n = int(input())
(xx, yy) = (set(), set())
for i in range(n):
	(x, y) = map(int, input().split())
	xx.add(x)
	yy.add(y)
print(min(len(xx), len(yy)))


n = int(input())
horizontal = set()
vertical = set()
for i in range(n):
	line = tuple(map(int, input().split()))[:]
	horizontal.add(line[0])
	vertical.add(line[1])
print(min(len(vertical), len(horizontal)))


n = int(input())
c = []
d = []
for i in range(n):
	(a, b) = [int(x) for x in input().split()]
	c.append(a)
	d.append(b)
print(min(len(set(c)), len(set(d))))


n = int(input())
a = []
b = []
for _ in range(n):
	xy = list(map(str, input().split()))
	a.append(xy[0])
	b.append(xy[1])
aa = list(set(a))
bb = list(set(b))
if len(aa) > len(bb):
	print(len(bb))
else:
	print(len(aa))


n = int(input())
x = []
y = []
for i in range(n):
	(x1, y1) = map(int, input().split())
	if x1 not in x:
		x.append(x1)
	if y1 not in y:
		y.append(y1)
print(min(len(x), len(y)))


t = int(input())
a = []
b = []
while t != 0:
	t -= 1
	(n, m) = map(int, input().split())
	a.append(n)
	b.append(m)
if len(set(a)) <= len(set(b)):
	print(len(set(a)))
else:
	print(len(set(b)))


n = int(input())
cnt1 = 0
cnt2 = 0
d1 = {}
d2 = {}
for i in range(n):
	(x, y) = map(int, input().split())
	if x not in d1:
		d1[x] = 1
		cnt1 += 1
	if y not in d2:
		cnt2 += 1
		d2[y] = 1
print(min(cnt1, cnt2))


n = int(input())
x = []
y = []
for i in range(n):
	(x_i, y_i) = map(int, input().split())
	x.append(x_i)
	y.append(y_i)
print(min(len(set(x)), len(set(y))))


q = int(input())
ar = []
for _ in range(q):
	s = input()
	ar.append(s.split(' '))
k = 0
ver = {}
hor = {}
for i in ar:
	if i[0] not in hor:
		hor[i[0]] = 1
	if i[1] not in ver:
		ver[i[1]] = 1
print(min(len(hor), len(ver)))


a = int(input().strip())
v = set()
h = set()
for i in range(a):
	cnt = [int(x) for x in input().strip().split(' ')]
	v.add(cnt[0])
	h.add(cnt[1])
print(min(len(v), len(h)))


n = int(input())
s = []
for _ in range(n):
	s.append([int(i) for i in input().split()])
q = set()
w = set()
for (i, j) in s:
	q.add(i)
	w.add(j)
print(min(len(q), len(w)))


x = set([])
y = set([])
for i in range(0, int(input())):
	coord = input().split(' ')
	x.add(list(coord)[0])
	y.add(list(coord)[1])
print(min(len(set(x)), len(set(y))))


n = int(input())
coordinetes = []
xset = set()
yset = set()
i = 1
while i <= n:
	(x, y) = input().split(' ')
	coordinetes.append({'x': int(x), 'y': int(y)})
	i += 1
for coordinete in coordinetes:
	xset.add(coordinete['x'])
	yset.add(coordinete['y'])
if len(xset) < len(yset):
	min = len(xset)
else:
	min = len(yset)
print(min)


n = int(input())
dr = {}
dc = {}
for i in range(n):
	li = [int(x) for x in input().split()]
	(x, y) = (li[0], li[1])
	if x in dr:
		dr[x] += 1
	else:
		dr[x] = 1
	if y in dc:
		dc[y] += 1
	else:
		dc[y] = 1
print(min(len(dr), len(dc)))


n = int(input())
hashrows = {}
hashcolumns = {}
for i in range(n):
	(a, b) = map(int, input().split())
	if a not in hashrows.keys():
		hashrows[a] = [[a, b]]
	else:
		hashrows[a].append([a, b])
	if b not in hashcolumns.keys():
		hashcolumns[b] = [[a, b]]
	else:
		hashcolumns[b].append([a, b])
print(min(len(hashrows), len(hashcolumns)))


x = [set(), set()]
for i in range(int(input())):
	m = input().split()
	for i in range(2):
		x[i].add(m[i])
print(min(map(len, x)))


def solve():
	n = int(input())
	(x, y) = ([], [])
	for i in range(n):
		(X, Y) = map(int, input().split())
		x.append(X)
		y.append(Y)
	y = list(set(y))
	x = list(set(x))
	print(min(len(x), len(y)))
solve()


n = int(input())
l = []
m = []
for _ in range(n):
	(x, y) = map(int, input().split())
	l.append(x)
	m.append(y)
p = len(set(l))
q = len(set(m))
print(min(p, q))


n = int(input())
x = []
y = []
final = 0
for _ in range(n):
	inp = input().split()
	if inp[0] not in x:
		x.append(inp[0])
	if inp[1] not in y:
		y.append(inp[1])
if len(y) >= len(x):
	print(len(x))
else:
	print(len(y))


from sys import stdin
all_in = stdin.readlines()
n = int(all_in[0])
dots = list(map(lambda x: tuple(map(int, x.split())), all_in[1:]))
x = set()
y = set()
for (x_, y_) in dots:
	x.add(x_)
	y.add(y_)
print(min(len(x), len(y)))


(a, b) = ([0] * 105, [0] * 105)
n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	a[x] = b[y] = 1
print(min(sum(a), sum(b)))


n = int(input())
a = []
b = []
for i in range(n):
	x = list(map(int, input().split(' ')))
	a.append(x[0])
	b.append(x[1])
print(min(len(set(a)), len(set(b))))


li = []
for _ in range(int(input())):
	li.append(tuple(map(int, input().split())))
dic_horizon = {}
for e in li:
	if e[0] not in dic_horizon:
		dic_horizon[e[0]] = 1
	else:
		dic_horizon[e[0]] += 1
dic_vertical = {}
for e in li:
	if e[1] not in dic_vertical:
		dic_vertical[e[1]] = 1
	else:
		dic_vertical[e[1]] += 1
print(min(len(dic_horizon), len(dic_vertical)))


n = int(input())
(x, y) = ([], [])
for _ in range(n):
	(a, b) = map(int, input().split())
	if a not in x:
		x.append(a)
	if b not in y:
		y.append(b)
print(min(len(x), len(y)))


n = int(input())
x = [0 for m in range(101)]
y = [0 for n in range(101)]
for i in range(n):
	(xi, yi) = map(int, input().split())
	x[xi] = 1
	y[yi] = 1
print(min(x.count(1), y.count(1)))


n = int(input())
seta = set()
sety = set()
while n:
	n -= 1
	(x, y) = map(int, input().split())
	seta.add(x)
	sety.add(y)
print(min(len(seta), len(sety)))


n = int(input())
x = set()
y = set()
for i in range(n):
	(j, k) = map(int, input().split(' '))
	x.add(j)
	y.add(k)
print(min(len(x), len(y)))


ac = int(input())
x = set()
y = set()
if ac > 0 and ac < 100001:
	for i in range(ac):
		(a, b) = map(int, input().split(' '))
		if a >= 0 and a <= 100 and (b >= 0) and (b <= 100):
			x.add(a)
			y.add(b)
	if len(x) < len(y):
		print(len(x))
	else:
		print(len(y))


n = int(input())
x = [0] * n
y = [0] * n
for t in range(n):
	(x[t], y[t]) = [int(x) for x in input().split()]
x = list(set(x))
y = list(set(y))
print(min(len(x), len(y)))


def sol():
	n = int(input())
	x = {}
	y = {}
	for i in range(n):
		(x_i, y_i) = map(int, input().split())
		x[x_i] = True
		y[y_i] = True
	print(min(len(x.keys()), len(y.keys())))
sol()


n = int(input())
coords = []
for i in range(n):
	coords.append(tuple((int(p) for p in input().split())))
H = []
V = []
for coord in coords:
	if coord[0] not in H:
		H.append(coord[0])
	if coord[1] not in V:
		V.append(coord[1])
print(min([len(H), len(V)]))


n = int(input())
x = {}
y = {}
for i in range(n):
	z = [int(i) for i in input().split()]
	if z[0] in x:
		x[z[0]] += 1
	else:
		x[z[0]] = 1
	if z[1] in y:
		y[z[1]] += 1
	else:
		y[z[1]] = 1
if len(x) > len(y):
	print(len(y))
else:
	print(len(x))


def unique(list1):
	unique_list = []
	count = 0
	for x in list1:
		if x not in unique_list:
			unique_list.append(x)
			count += 1
	return count
n = int(input())
lx = []
ly = []
for i in range(n):
	(x, y) = map(int, input().split())
	lx.append(x)
	ly.append(y)
x = unique(lx)
y = unique(ly)
print(min(x, y))


l1 = [0] * 101
l2 = [0] * 101
n = int(input())
for li in range(n):
	(x, y) = input().split(' ')
	a = int(x)
	b = int(y)
	l1[a] = 1
	l2[b] = 1
print(min(sum(l1), sum(l2)))


def countDistinct(arr, n):
	arrr = 0
	ar = []
	for elem in arr:
		if elem not in ar:
			arrr += 1
			ar.append(elem)
	return arrr
n = int(input())
x = []
y = []
for i in range(n):
	(a, b) = map(int, input().split())
	x.append(a)
	y.append(b)
print(min(countDistinct(x, n), countDistinct(y, n)))


n = int(input())
(x_coor, y_coord) = ([], [])
for i in range(0, n):
	(x, y) = map(int, input().split())
	x_coor.append(x)
	y_coord.append(y)
print(min(len(set(x_coor)), len(set(y_coord))))


x = [0] * 101
y = [0] * 101
n = int(input())
for i in range(n):
	(a, b) = [int(z) for z in input().split()]
	x[a] = 1
	y[b] = 1
print(min(sum(x), sum(y)))


xd = []
yd = []
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	xd.append(x)
	yd.append(y)
print(min(len(set(xd)), len(set(yd))))


n = int(input())
hor = []
ver = []
for i in range(n):
	s = input().split()
	hor.append(s[1])
	ver.append(s[0])
print(min(len(set(hor)), len(set(ver))))


n = int(input())
(a, b) = ([], [])
for i in range(n):
	(a0, b0) = map(int, input().split())
	a.append(a0)
	b.append(b0)
v1 = set(a)
v2 = set(b)
print(min(len(v1), len(v2)))


n = int(input())
(x, y) = ([], [])
for i in range(n):
	c = input().split(' ')
	if c[0] not in x:
		x.append(c[0])
	if c[1] not in y:
		y.append(c[1])
if len(x) > len(y):
	print(len(y))
else:
	print(len(x))


n = int(input())
x = {}
y = {}
for i in range(n):
	(a, b) = [int(i) for i in input().split()]
	x[a] = 0
	y[b] = 0
print(len(x) if len(x) <= len(y) else len(y))


n = int(input())
M = [input().split() for i in range(n)]
row = []
col = []
for i in range(n):
	row.append(M[i][0])
	col.append(M[i][1])
x = len(set(row))
y = len(set(col))
print(min(x, y))


n = int(input())
(x, y) = ([], [])
for i in range(n):
	(m, n) = map(int, input().split())
	x.append(m)
	y.append(n)
if len(set(x)) > len(set(y)):
	print(len(set(y)))
if len(set(x)) < len(set(y)):
	print(len(set(x)))
if len(set(x)) == len(set(y)):
	print(len(set(y)))


n = int(input())
x = set()
y = set()
for i in range(n):
	cad = input().split()
	x.add(cad[0])
	y.add(cad[1])
if len(x) > len(y):
	print(len(y))
else:
	print(len(x))


relojes = int(input())
x = []
y = []
for i in range(relojes):
	ubicacion = list(map(int, input().split()))
	if ubicacion[1] not in x:
		x += [ubicacion[1]]
	if ubicacion[0] not in y:
		y += [ubicacion[0]]
print(min(len(x), len(y)))


import sys
import math
import collections
import heapq
import decimal
input = sys.stdin.readline
n = int(input())
s1 = set()
s2 = set()
for i in range(n):
	(a, b) = (int(i) for i in input().split())
	s1.add(a)
	s2.add(b)
print(min(len(s1), len(s2)))


N = int(input())
Hor = Ver = 1
H = []
V = []
for I in range(N):
	Tmp = list(map(int, input().split()))
	H += [Tmp[0]]
	V += [Tmp[1]]
H.sort()
V.sort()
Tmp1 = H[0]
Tmp2 = V[0]
for I in range(1, N):
	Hor += 1 if not Tmp1 == H[I] else 0
	Ver += 1 if not Tmp2 == V[I] else 0
	Tmp1 = H[I]
	Tmp2 = V[I]
print(min(Hor, Ver))


v = set()
g = set()
for i in range(int(input())):
	(a, b) = input().split()
	v.add(a)
	g.add(b)
print(min(len(v), len(g)))


q = int(input())
set1 = set()
set2 = set()
for i in range(q):
	(a, b) = map(int, input().split())
	set1.add(a)
	set2.add(b)
print(min(len(set1), len(set2)))


n = int(input())
(V, H) = ([False] * 101, [False] * 101)
for _ in range(n):
	(x, y) = list(map(int, input().split()))
	V[x] = True
	H[y] = True
print(min(V.count(True), H.count(True)))


import sys

def main():
	n = int(sys.stdin.readline())
	collumns = [0 for _ in range(101)]
	rows = [0 for _ in range(101)]
	for _ in range(n):
		(x, y) = [int(v) for v in sys.stdin.readline().strip().split()]
		collumns[x] += 1
		rows[y] += 1
	print(min(len([v for v in collumns if v > 0]), len([v for v in rows if v > 0])))
main()


n = int(input())
x = [0 for i in range(101)]
y = [0 for i in range(101)]
x_num = 0
y_num = 0
for k in range(n):
	(i, j) = [int(s) for s in input().split()]
	if x[i] == 0:
		x_num += 1
		x[i] = 1
	if y[j] == 0:
		y_num += 1
		y[j] += 1
if y_num > x_num:
	print('%d\n' % x_num)
else:
	print('%d\n' % y_num)


n = int(input())
(X, Y) = ([None] * n, [None] * n)
for i in range(n):
	(X[i], Y[i]) = tuple(map(int, input().split()))
(set_x, set_y) = (set(X), set(Y))
fn = lambda x, y: min(len(x), len(y))
print(fn(set_x, set_y))


X = []
Y = []
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	if x not in X:
		X.append(x)
	if y not in Y:
		Y.append(y)
print(min(len(X), len(Y)))


n = int(input())
x = []
y = []
for i in range(n):
	(xt, yt) = list(map(int, input().split()))
	x.append(xt)
	y.append(yt)
x = list(set(x))
y = list(set(y))
print(min(len(x), len(y)))


a = set()
b = set()
clock = int(input())
for i in range(clock):
	(c, d) = list(map(int, input().split()))
	a.add(c)
	b.add(d)
print(min(len(a), len(b)))


n = int(input())
xset = set()
yset = set()
l = list((tuple(map(int, input().split())) for _ in range(n)))
for a in l:
	xset.add(a[0])
	yset.add(a[1])
print(min(len(xset), len(yset)))


n = int(input())
x = [0 for i in range(101)]
y = [0 for i in range(101)]
for i in range(n):
	(a, b) = map(int, input().split())
	x[a] += 1
	y[b] += 1
xdif = 0
ydif = 0
for i in range(101):
	if x[i] != 0:
		xdif += 1
	if y[i] != 0:
		ydif += 1
print(min(xdif, ydif))


n = int(input())
x = []
y = []
pairs = set()
l = 0
for _ in range(n):
	(i, j) = map(int, input().split())
	if (i, j) not in pairs:
		pairs.add((i, j))
		x.append(i)
		y.append(j)
		l = l + 1
vert = []
hor = []
for _ in range(101):
	vert.append(0)
	hor.append(0)
for k in range(l):
	vert[y[k]] = vert[y[k]] + 1
	hor[x[k]] = hor[x[k]] + 1
non_zeroes_ver = 0
non_zeroes_hor = 0
for k in range(101):
	if vert[k] > 0:
		non_zeroes_ver = non_zeroes_ver + 1
for k in range(101):
	if hor[k] > 0:
		non_zeroes_hor = non_zeroes_hor + 1
if non_zeroes_hor < non_zeroes_ver:
	print(non_zeroes_hor)
else:
	print(non_zeroes_ver)


n = int(input())
vert = set()
hor = set()
for _ in range(n):
	(x, y) = map(int, input().split())
	vert.add(x)
	hor.add(y)
print(min(len(vert), len(hor)))


num = int(input())
hor = set()
ver = set()
for i in range(num):
	inp = list(map(int, input().split()))
	hor.add(inp[0])
	ver.add(inp[1])
print(min(len(hor), len(ver)))


n = int(input())
L = [input().split() for i in range(n)]
X = set()
Y = set()
for coord in L:
	X.add(coord[0])
	Y.add(coord[1])
print(min(len(X), len(Y)))


def inna_and_alarm_clock(alarms_list) -> int:
	rc_dict = dict()
	for (row, column) in alarms_list:
		if rc_dict.get((row, 'r'), (0, 'r')) == (0, 'r'):
			rc_dict[row, 'r'] = 1
		else:
			rc_dict[row, 'r'] += 1
		if rc_dict.get((column, 'c'), (0, 'c')) == (0, 'c'):
			rc_dict[column, 'c'] = 1
		else:
			rc_dict[column, 'c'] += 1
	row_count = 0
	column_count = 0
	for (_, r_or_c) in rc_dict:
		if r_or_c == 'r':
			row_count += 1
		else:
			column_count += 1
	if row_count <= column_count:
		return row_count
	else:
		return column_count
n = int(input())
alarms = [tuple(map(int, input().split())) for i in range(n)]
print(inna_and_alarm_clock(alarms))


from collections import defaultdict
n = int(input())
x_cords = defaultdict(int)
y_cords = defaultdict(int)
for i in range(n):
	(x, y) = [int(v) for v in input().split()]
	x_cords[x] += 1
	y_cords[y] += 1
print(min(len(x_cords), len(y_cords)))


def main():
	n = int(input())
	r = set()
	c = set()
	for i in range(n):
		(x, y) = list(map(int, input().split(' ')))
		r.add(y)
		c.add(x)
	return min(len(r), len(c))
print(main())


n = int(input())
d1 = {}
d2 = {}
for i in range(n):
	(x, y) = map(int, input().split())
	if x not in d1:
		d1[x] = 1
	if y not in d2:
		d2[y] = 1
print(min(len(d1), len(d2)))


n = int(input())
vertical = set()
horizontal = set()
for i in range(n):
	(x, y) = map(int, input().split())
	vertical.add(y)
	horizontal.add(x)
print(len(vertical) if len(vertical) < len(horizontal) else len(horizontal))


n = int(input())
(dpx, dpy) = (set(), set())
for i in range(n):
	(x, y) = map(int, input().split())
	dpx.add(x)
	dpy.add(y)
print(min(len(dpx), len(dpy)))


MAX_VALUE = 10 ** 5 + 1

def main():
	n = int(input())
	coords = []
	for i in range(n):
		coords.append([int(j) for j in input().split()])
	on_x = [False for i in range(MAX_VALUE)]
	on_y = [False for i in range(MAX_VALUE)]
	for i in coords:
		on_x[i[0]] = True
		on_y[i[1]] = True
	max_x = 0
	max_y = 0
	for i in range(MAX_VALUE):
		if on_x[i]:
			max_x += 1
		if on_y[i]:
			max_y += 1
	return min(max_x, max_y)
print(main())


n = int(input())
p = []
for i in range(n):
	p.append([int(x) for x in input().split(' ')])
x = set()
y = set()
for point in p:
	x.add(point[0])
	y.add(point[1])
print(min(len(x), len(y)))


n = int(input())
x = []
y = []
for i in range(n):
	(x1, y1) = map(int, input().split())
	x.append(x1)
	y.append(y1)
x = list(dict.fromkeys(x))
y = list(dict.fromkeys(y))
print(min(len(x), len(y)))


def minMoves(x, y):
	return min(sum(x), sum(y))
MAX = 101
n = int(input())
x = [0] * MAX
y = [0] * MAX
for i in range(n):
	(a, b) = map(int, input().split())
	x[a] = 1
	y[b] = 1
print(minMoves(x, y))


n = int(input())
listx = []
listy = []
for i in range(0, n):
	a = input().split()
	y = int(a[1])
	x = int(a[0])
	listx.append(x)
	listy.append(y)
setx = set(listx)
sety = set(listy)
mylist = [len(setx), len(sety)]
print(min(mylist))


n = int(input())
same_hor = same_ver = 0
hors = []
vers = []
for _ in range(n):
	coords = input()
	x = int(coords.split(' ')[0])
	y = int(coords.split(' ')[1])
	if x in hors:
		same_hor += 1
	else:
		hors.append(x)
	if y in vers:
		same_ver += 1
	else:
		vers.append(y)
if same_hor > same_ver:
	print(len(hors))
else:
	print(len(vers))


from sys import stdin
from collections import Counter
n = int(input())
alert = [tuple(input().split()) for i in range(n)]
(xs, ys) = zip(*alert)
cx = Counter(map(int, xs))
cy = Counter(map(int, ys))
print(min(len(cx), len(cy)))


def count_numbers_repeated(arr, n):
	arr = sorted(arr)
	count = 0
	for i in range(n - 1):
		if arr[i] != arr[i + 1]:
			count = count + 1
	return count
n = int(input())
rows = [None] * n
columns = [None] * n
for i in range(n):
	ele = list(map(int, input().split()))
	rows[i] = ele[0]
	columns[i] = ele[1]
f = count_numbers_repeated(rows, n) + 1
c = count_numbers_repeated(columns, n) + 1
if f <= c:
	print(f)
else:
	print(c)


n = int(input())
l1 = [0] * 105
l2 = [0] * 105
x = 0
y = 0
for i in range(n):
	ln = input().split()
	l = [int(ln[i]) for i in range(len(ln))]
	if not l1[l[0]]:
		l1[l[0]] = 1
		x += 1
	if not l2[l[1]]:
		l2[l[1]] = 1
		y += 1
print(min(x, y))


n = int(input())
clocks = []
lengths_vertical = [0] * 101
lengths_horizontal = [0] * 101
for i in range(n):
	(x, y) = input().split()
	(x, y) = (int(x), int(y))
	lengths_horizontal[x] += 1
	lengths_vertical[y] += 1
max_clocks_horizontal = sum([1 if x > 0 else 0 for x in lengths_horizontal])
max_clocks_vertical = sum([1 if x > 0 else 0 for x in lengths_vertical])
print(min(max_clocks_horizontal, max_clocks_vertical))


n = int(input())
x = []
y = []
for i in range(n):
	(xi, yi) = list(map(int, input().split()))
	x.append(xi)
	y.append(yi)
x = set(x)
y = set(y)
print(min(len(x), len(y)))


n = int(input())
useX = [False] * 101
useY = [False] * 101
cntX = 0
cntY = 0
for i in range(n):
	(x, y) = input().split(' ')
	x = int(x)
	y = int(y)
	cntX += 0 if useX[x] else 1
	cntY += 0 if useY[y] else 1
	useX[x] = True
	useY[y] = True
print(cntX if cntX < cntY else cntY)


n = int(input())
X = set()
Y = set()
for i in range(n):
	(x, y) = map(int, input().split())
	X.add(x)
	Y.add(y)
print(min(len(X), len(Y)))


from sys import stdin, stdout
n = int(stdin.readline().strip())
lst1 = [0] * 101
lst2 = [0] * 101
for i in range(n):
	point = list(map(int, stdin.readline().strip().split()))
	if lst1[point[0]] == 0:
		lst1[point[0]] = 1
	if lst2[point[1]] == 0:
		lst2[point[1]] = 1
print(min(sum(lst1), sum(lst2)))


n = int(input())
(v, h) = (set(), set())
for i in range(n):
	(x, y) = map(int, input().split())
	v.add(x)
	h.add(y)
print(min(len(v), len(h)))


n = int(input())
alert = [tuple(input().split()) for i in range(n)]
ans = min(map(lambda x: len(set(x)), zip(*alert)))
print(ans)


n = int(input())
x = []
y = []
nLinesX = 0
nLinesY = 0
for i in range(n):
	tempInput = input()
	if tempInput.split()[0] not in x:
		x.append(tempInput.split()[0])
		nLinesX += 1
	if tempInput.split()[1] not in y:
		y.append(tempInput.split()[1])
		nLinesY += 1
print(sorted([nLinesX, nLinesY])[0])


d1 = {}
d2 = {}
n = int(input())
l = []
for i in range(n):
	x = list(map(int, input().split()))
	l.append(x)
for i in range(n):
	if l[i][0] not in d1:
		d1[l[i][0]] = 1
sum1 = sum(d1.values())
for i in range(n):
	if l[i][1] not in d2:
		d2[l[i][1]] = 1
sum2 = sum(d2.values())
print(sum1) if sum1 <= sum2 else print(sum2)


n = int(input())
x = []
y = []
for i in range(n):
	array = input().split()
	array = list(map(lambda x: int(x) if x.isdigit() else 0, array))
	if x.count(array[0]) == 0:
		x.append(array[0])
	if y.count(array[1]) == 0:
		y.append(array[1])
print(min(len(x), len(y)))


no_of_alarms = int(input())
x_set = set()
y_set = set()
while no_of_alarms > 0:
	i_alarm = input().split()
	x_set.add(int(i_alarm[0]))
	y_set.add(int(i_alarm[1]))
	no_of_alarms = no_of_alarms - 1
if len(x_set) <= len(y_set):
	print(len(x_set))
else:
	print(len(y_set))


n = int(input())
s1 = set()
s2 = set()
for i in range(n):
	(a, b) = map(int, input().split())
	s1.add(a)
	s2.add(b)
s = min(len(s1), len(s2))
print(s)


d = {}
d1 = {}
q = int(input())
for _ in range(q):
	b = []
	for a in input().split():
		b.append(int(a))
	try:
		d[b[0]] += 1
	except KeyError:
		d[b[0]] = 1
	try:
		d1[b[1]] += 1
	except KeyError:
		d1[b[1]] = 1
print(min(len(d.keys()), len(d1.keys())))


a1 = []
b1 = []
k3 = 0
k4 = 0
n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	a1 += [a]
	b1 += [b]
for i in range(101):
	if i in a1:
		k3 += 1
	if i in b1:
		k4 += 1
print(min(k3, k4))


n = int(input())
countx = county = 0
arrx = []
arry = []
x = y = 0
for i in range(0, n):
	(x, y) = map(int, input().split(' '))
	if x not in arrx:
		countx += 1
		arrx.append(x)
	if y not in arry:
		county += 1
		arry.append(y)
print(min(countx, county))


from collections import Counter
k = int(input())
(setx, sety) = (set(), set())
for i in range(k):
	(x, y) = list(map(int, input().split()))
	setx.add(x)
	sety.add(y)
print(min(len(setx), len(sety)))


n = int(input())
x_cord = []
y_cord = []
for i in range(n):
	e = input().split()
	x_cord.append(e[0])
	y_cord.append(e[1])
set_x = set(x_cord)
set_y = set(y_cord)
if len(set_x) < len(set_y):
	print(len(set_x))
else:
	print(len(set_y))


from collections import defaultdict
lx = defaultdict(list)
ly = defaultdict(list)
l = list()
for i in range(int(input())):
	l.append(input())
for x in l:
	a = x.split()
	lx[a[0]].append(a[1])
	ly[a[1]].append(a[0])
print(min(len(lx), len(ly)))


n = int(input())
x_set = set()
y_set = set()
for i in range(n):
	(x, y) = map(int, input().split())
	x_set.add(x)
	y_set.add(y)
print(min(len(x_set), len(y_set)))


amount_alarms = int(input())
setx = set()
sety = set()
for _ in range(amount_alarms):
	(x, y) = map(int, input().split())
	setx.add(x)
	sety.add(y)
print(min(len(setx), len(sety)))


lv = [0] * 101
lg = [0] * 101
for i in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	lv[a] = 1
	lg[b] = 1
print(min(sum(lv), sum(lg)))


def inna_and_alarm_clock(n: int, points: list) -> int:
	(ver, hor) = (set(), set())
	for (x, y) in points:
		ver.add(x)
		hor.add(y)
	return min(len(ver), len(hor))
n = int(input())
points = [tuple((int(s) for s in input().split())) for _ in range(n)]
ans = inna_and_alarm_clock(n, points)
print(ans)


from math import *
x = set()
y = set()
for i in range(int(input())):
	(a, b) = map(int, input().split())
	x.add(a)
	y.add(b)
print(min(len(x), len(y)))


s = set()
p = set()
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	s.add(x)
	p.add(y)
print(min(len(s), len(p)))


def horizontal(array):
	answer = set()
	for i in range(len(array)):
		answer.add(array[i][1])
	return len(answer)

def vertical(array):
	answer = set()
	for i in range(len(array)):
		answer.add(array[i][0])
	return len(answer)
num_clock = int(input())
coordinates = []
for i in range(num_clock):
	coordinates.append([int(i) for i in input().split()])
print(min(horizontal(coordinates), vertical(coordinates)))


n = int(input())
arr1 = []
arr2 = []
for i in range(n):
	l = [int(i) for i in input().split()]
	arr1.append(l[0])
	arr2.append(l[1])
j1 = [0 for i in range(101)]
j2 = [0 for i in range(101)]
for i in arr1:
	j1[i] += 1
for i in arr2:
	j2[i] += 1
a = j1.count(0)
b = j2.count(0)
print(101 - max(a, b))


t = int(input())
v = set()
h = set()
arr = []
for i in range(t):
	arr.append(list(map(int, input().split())))
for i in arr:
	h.add(i[1])
for i in arr:
	v.add(i[0])
print(min(len(h), len(v)))


n = int(input())
x = set()
y = set()
for _ in range(n):
	a = list(map(int, input().rstrip().split()))
	x.add(a[0])
	y.add(a[1])
print(min(len(x), len(y)))


n = int(input())
s = set()
t = set()
for _ in range(n):
	(x, y) = map(int, input().split())
	s.add(x)
	t.add(y)
print(min(len(s), len(t)))


hor_l = set()
ver_l = set()
for _ in range(int(input())):
	(x, y) = [int(i) for i in input().split(' ')]
	hor_l.add(x)
	ver_l.add(y)
l = len(hor_l)
if len(ver_l) < l:
	l = len(ver_l)
print(l)


clocks = int(input())
crds = []
(j, k) = (set(), set())
for i in range(clocks):
	aa = [int(a) for a in input().split()]
	crds.append(aa)
for i in crds:
	j.add(i[0])
	k.add(i[1])
print(min(len(j), len(k)))


n = int(input())
x = []
y = []
for i in range(n):
	clockInt = input()
	xInt = int(clockInt.split(' ')[0])
	yInt = int(clockInt.split(' ')[1])
	if xInt in x:
		pass
	else:
		x.append(xInt)
	if yInt in y:
		pass
	else:
		y.append(yInt)
print(min(len(x), len(y)))


n = int(input())
x = []
y = []
for i in range(n):
	(p, q) = map(int, input().split())
	x.append(p)
	y.append(q)
print(min(len(list(set(x))), len(list(set(y)))))


n = int(input())
L1 = set()
L2 = set()
for i in range(n):
	(x, y) = [int(x) for x in input().split()]
	L1.add(x)
	L2.add(y)
print(min(len(L1), len(L2)))


def solve(alarms):
	x_set = set()
	y_set = set()
	for (x, y) in alarms:
		assert 0 <= x <= 100
		assert 0 <= y <= 100
		x_set.add(x)
		y_set.add(y)
	return min(len(x_set), len(y_set))

def main():
	n = int(input())
	alarms = list()
	for _ in range(n):
		(x, y) = list(map(int, input().split()))
		alarms.append((x, y))
	print(solve(alarms))
main()


def function():
	pass

def main():
	n = int(input())
	xset = set()
	yset = set()
	for i in range(n):
		(x, y) = map(int, input().strip().split())
		xset.add(x)
		yset.add(y)
	print(min(len(xset), len(yset)))
main()


from itertools import islice, count
counter = int(input())
horizontal = set()
vertical = set()
for x in islice(count(1), counter):
	(x, y) = input().split()
	horizontal.add(x)
	vertical.add(y)
if len(horizontal) < len(vertical):
	print(len(horizontal))
else:
	print(len(vertical))


s = int(input())
y_list = []
x_list = []
input_list = []
for i in range(s):
	input_list += [int(x) for x in input().split(' ')]
for i in range(len(input_list)):
	if i % 2 == 0:
		x_list += [input_list[i]]
	else:
		y_list += [input_list[i]]
print(min(len(set(x_list)), len(set(y_list))))


import collections
n = int(input())
x = []
y = []
for i in range(n):
	(newx, newy) = map(int, input().strip().split())
	x.append(newx)
	y.append(newy)
print(min(len(set(x)), len(set(y))))


class CodeforcesTask390ASolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.rings = []

	def read_input(self):
		self.n = int(input())
		for x in range(self.n):
			self.rings.append([int(y) for y in input().split(' ')])

	def process_task(self):
		ys = [x[0] for x in self.rings]
		xs = [x[1] for x in self.rings]
		self.result = str(min(len(set(ys)), len(set(xs))))

	def get_result(self):
		return self.result
Solution = CodeforcesTask390ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


xs = set()
ys = set()
for _ in range(int(input())):
	(x, y) = input().split()
	xs.add(x)
	ys.add(y)
print(min(len(xs), len(ys)))


a = set()
b = set()
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	a.add(x)
	b.add(y)
print(min(len(a), len(b)))


n = int(input())
x = []
y = []
for i in range(n):
	t = list(map(int, input().split(' ')))
	x.append(t[0])
	y.append(t[1])
xs = list(set(x))
ys = list(set(y))
print(min(len(xs), len(ys)))


n = int(input())
(q, w) = (set(), set())
for i in range(n):
	(a, b) = map(int, input().split())
	q.add(a)
	w.add(b)
print(min(len(q), len(w)))


n = int(input())
x = [0] * 101
y = [0] * 101
for _ in range(n):
	(i, j) = map(int, input().split())
	x[i] = 1
	y[j] = 1
print(min(sum(x), sum(y)))


x = set()
y = set()
for i in range(int(input())):
	(xi, yi) = [int(i) for i in input().split()]
	x.add(xi)
	y.add(yi)
print(min(len(x), len(y)))


n = int(input())
l1 = []
l2 = []
for i in range(n):
	(x, y) = map(int, input().split())
	l1.append(x)
	l2.append(y)
l1 = set(l1)
l2 = set(l2)
print(min(len(l1), len(l2)))


def do():
	n = int(input())
	xs = set()
	ys = set()
	for _ in range(n):
		(x, y) = map(int, input().split(' '))
		xs.add(x)
		ys.add(y)
	return min(len(xs), len(ys))
print(do())


def main():
	n = int(input())
	v = []
	h = []
	for i in range(n):
		(a, b) = map(int, input().split())
		v.append(a)
		h.append(b)
	lv = len(set(v))
	lh = len(set(h))
	res = lv if lv < lh else lh
	print(res)
main()


n = int(input())
xarr = []
yarr = []
for i in range(n):
	(x, y) = map(int, input().split())
	xarr.append(x)
	yarr.append(y)
print(min(len(set(xarr)), len(set(yarr))))


a = int(input())
b = []
c = []
for i in range(a):
	(x, y) = map(int, input().split())
	b.append(x)
	c.append(y)
print(min(len(set(b)), len(set(c))))


n = int(input())
memo_x = {}
memo_y = {}
for i in range(n):
	(x, y) = list(map(int, input().split()))
	if x in memo_x:
		memo_x[x] += 1
	else:
		memo_x[x] = 1
	if y in memo_y:
		memo_y[y] += 1
	else:
		memo_y[y] = 1
print(min(len(memo_x), len(memo_y)))