Given $n$ two-dimensional points in space, determine whether they lie on some vertical or horizontal line. If yes, print YES; otherwise, print NO.

Input Format

The first line contains a single positive integer, $n$, denoting the number of points. 

Each line $\boldsymbol{i}$ of $n$ subsequent lines contain two space-separated integers detailing the respective values of $x_i$ and $y_i$ (i.e., the coordinates of the $i^{\mbox{th}}$ point).

Constraints

$2\leq n\leq10$
$-10\leq x_i,y_i\leq10$

Output Format

Print YES if all points lie on some horizontal or vertical line; otherwise, print NO.

Sample Input 0
5
0 1
0 2
0 3
0 4
0 5

Sample Output 0
YES

Explanation 0

All points lie on a vertical line.

Sample Input 1
5
0 1
0 2
1 3
0 4
0 5

Sample Output 1
NO

Explanation 1

The points do not all form a horizontal or vertical line.

Source: hackerrank | Difficulty: EASY
Tags: Geometry


Solutions:
import sys
n = int(input().strip())
sx = set()
sy = set()
for a0 in range(n):
	(x, y) = map(int, input().strip().split(' '))
	sx.update({x})
	sy.update({y})
print('YES' if len(sx) == 1 or len(sy) == 1 else 'NO')


n = int(input())
p = [list(map(int, input().split())) for i in range(n)]
if all((p[0][0] == p[i][0] for i in range(n))) or all((p[0][1] == p[i][1] for i in range(n))):
	print('YES')
else:
	print('NO')


n = int(input())
x = [0] * n
y = [0] * n
for i in range(n):
	(x[i], y[i]) = map(int, input().split())
if min(x) == max(x) or min(y) == max(y):
	print('YES')
else:
	print('NO')


import sys
xs = []
ys = []
n = int(input().strip())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	xs.append(x)
	ys.append(y)
if len(set(xs)) == 1 or len(set(ys)) == 1:
	print('YES')
else:
	print('NO')


n = int(input())
(x, y) = map(int, input().split())
(a, b) = (True, True)
for i in range(n - 1):
	(c, d) = map(int, input().split())
	a = a and c == x
	b = b and d == y
print('YES' if a or b else 'NO')


import sys
n = int(input().strip())
(hori, verti) = (True, True)
(h, v) = (None, None)
while n > 0:
	(x, y) = list(map(int, input().split()))
	if h == None:
		h = x
		v = y
	else:
		if x != h:
			hori = False
		if y != v:
			verti = False
	n -= 1
if hori or verti:
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
ax = set()
ay = set()
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	ax.add(x)
	ay.add(y)
if len(ax) == 1 or len(ay) == 1:
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
points = list()
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	points.append((x, y))
h = v = True
for i in range(1, n):
	(x, y) = points[i]
	(xo, yo) = points[i - 1]
	if h:
		if yo != y:
			h = False
	if v:
		if xo != x:
			v = False
	if not h and (not v):
		print('NO')
		exit(0)
print('YES')


import sys

def allEqualX(listX):
	for elem in listX:
		if elem != listX[0]:
			return False
	return True

def allEqualY(listY):
	for elem in listY:
		if elem != listY[0]:
			return False
	return True
n = int(input().strip())
listX = []
listY = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	listX.append(x)
	listY.append(y)
if allEqualX(listX) or allEqualY(listY):
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
xx = []
yy = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	xx.append(x)
	yy.append(y)
fx = 1
fy = 1
for i in range(1, len(xx)):
	if xx[i - 1] != xx[i]:
		fx = 0
		break
for i in range(1, len(yy)):
	if yy[i - 1] != yy[i]:
		fy = 0
		break
if fx or fy:
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())

def f():
	(x0, y0) = input().strip().split(' ')
	(x0, y0) = [int(x0), int(y0)]
	(xs, ys) = (True, True)
	for a0 in range(n - 1):
		(x, y) = input().strip().split(' ')
		(x, y) = [int(x), int(y)]
		if x != x0:
			xs = False
		if y != y0:
			ys = False
		if not xs and (not ys):
			return 'NO'
	return 'YES'
print(f())


import sys
n = int(input().strip())
xx = []
yy = []
for _ in range(n):
	(x, y) = map(int, input().split(' '))
	xx.append(x)
	yy.append(y)
if all((xx[0] == x for x in xx[1:])) or all((yy[0] == y for y in yy[1:])):
	print('YES')
else:
	print('NO')


import sys

def find(l):
	for i in range(len(l) - 1):
		if l[i] != l[i + 1]:
			return False
	return True
n = int(input().strip())
l1 = []
l2 = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	l1.append(x)
	l2.append(y)
if find(l1) or find(l2):
	print('YES')
else:
	print('NO')


import sys

def is_vertical(points):
	for (x, _) in points[1:]:
		if points[0][0] != x:
			return False
	return True

def is_horizontal(points):
	for (_, y) in points[1:]:
		if points[0][1] != y:
			return False
	return True
n = int(input().strip())
points = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	points.append((x, y))
if not (is_horizontal(points) or is_vertical(points)):
	print('NO')
else:
	print('YES')


import sys
n = int(input().strip())

def checkEqual(lst):
	return lst[1:] == lst[:-1]
xn = []
yn = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	xn.append(x)
	yn.append(y)
if checkEqual(xn) or checkEqual(yn):
	print('YES')
else:
	print('NO')


import sys
from collections import Counter
n = int(input().strip())
(cx, cy) = (Counter(), Counter())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	cx[x] += 1
	cy[y] += 1
if len(cx) == 1 or len(cy) == 1:
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
p = []
for i in range(n):
	(x, y) = input().strip().split(' ')
	p.append((int(x), int(y)))
allx = True
ally = True
for i in range(1, n):
	if p[i][0] != p[0][0]:
		allx = False
	if p[i][1] != p[0][1]:
		ally = False
if allx or ally:
	print('YES')
else:
	print('NO')


import sys
xarr = []
yarr = []
n = int(input().strip())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	xarr.append(x)
	yarr.append(y)
var1 = True
for x in xarr:
	if x != xarr[0]:
		var1 = False
var2 = True
for y in yarr:
	if y != yarr[0]:
		var2 = False
if not var1 and (not var2):
	print('NO')
else:
	print('YES')


import sys
is_x = True
is_y = True
prev_x = None
prev_y = None
n = int(input().strip())
(prev_x, prev_y) = input().strip().split(' ')
(prev_x, prev_y) = [int(prev_x), int(prev_y)]
for a0 in range(1, n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	is_x = (x == prev_x and is_x) and True or False
	is_y = (y == prev_y and is_y) and True or False
	prev_x = x
	prev_y = y
msg = (is_x or is_y) and 'YES' or 'NO'
print(msg)


a = int(input())
m = list()
n = list()
while a > 0:
	data = input()
	data = data.split()
	m.append(int(data[0]))
	n.append(int(data[1]))
	a -= 1
fl = 0
fl2 = 0
for i in range(len(m) - 1):
	if m[i] != m[i + 1]:
		fl = 1
		break
for j in range(len(n) - 1):
	if n[j] != n[j + 1]:
		fl2 = 1
		break
if fl == 0 or fl2 == 0:
	print('YES')
else:
	print('NO')


l = []
a = []
b = []
for i in range(int(input())):
	t = [int(x) for x in input().split()]
	if t[0] not in a:
		a.append(t[0])
	if t[1] not in b:
		b.append(t[1])
if len(a) == 1 or len(b) == 1:
	print('YES')
else:
	print('NO')


xSet = set()
ySet = set()
coordList = []
n = int(input().strip())
for a in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	coordList.append((x, y))
for i in coordList:
	xSet.add(i[0])
	ySet.add(i[1])
if len(xSet) == 1 or len(ySet) == 1:
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(p, o) = (True, True)
for a0 in range(n - 1):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	if x != a:
		p = False
	if y != b:
		o = False
	if p == False and o == False:
		break
if p or o:
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
all_points = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	all_points.append((x, y))
x_cord = [tp[0] for tp in all_points]
y_cord = [tp[1] for tp in all_points]
if len(set(x_cord)) == 1 or len(set(y_cord)) == 1:
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
(xs, ys) = ([], [])
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	xs.append(x)
	ys.append(y)
for i in range(n):
	if xs[i] != xs[0]:
		for j in range(n):
			if ys[j] != ys[0]:
				print('NO')
				break
		else:
			print('YES')
		break
else:
	print('YES')


from sys import stderr

def read(f):
	return f(input())

def readlist(f):
	return [f(x) for x in input().split()]
n = read(int)
(x0, y0) = readlist(int)
(x1, y1) = readlist(int)
nx = y1 - y0
ny = x0 - x1
nc = nx * x0 + ny * y0
line = nx == 0 or ny == 0
for _ in range(2, n):
	if not line:
		break
	(x, y) = readlist(int)
	if nx * x + ny * y != nc:
		line = False
		break
print('YES' if line else 'NO')


import sys

def check(li):
	horiz = True
	verti = True
	horiz_start = None
	verti_start = None
	for i in li:
		x = i[0]
		y = i[1]
		if not horiz_start:
			horiz_start = x
		elif horiz_start != x:
			horiz = False
		if not verti_start:
			verti_start = y
		elif verti_start != y:
			verti = False
		if not horiz and (not verti):
			return 'NO'
	return 'YES'
n = int(input().strip())
li = list()
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	li.append((x, y))
print(check(li))


import sys
n = int(input().strip())
points = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	points.append((int(x), int(y)))
hor = True
ver = True
(x0, y0) = points[0]
for (x, y) in points[1:]:
	if ver and x != x0:
		ver = False
	if hor and y != y0:
		hor = False
	if not (ver or hor):
		break
print('YES' if ver or hor else 'NO')


import sys
n = int(input().strip())
dictX = {}
dictY = {}
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	if x not in dictX:
		dictX[x] = 1
	else:
		dictX[x] += 1
	if y not in dictY:
		dictY[y] = 1
	else:
		dictY[y] += 1
ans = 'NO'
for (key, value) in dictX.items():
	if value == n:
		ans = 'YES'
for (key, value) in dictY.items():
	if value == n:
		ans = 'YES'
print(ans)


import sys
n = int(input().strip())
X = []
Y = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	X += [x]
	Y += [y]
xans = True
for x in X:
	if x != X[0]:
		xans = False
yans = True
for y in Y:
	if y != Y[0]:
		yans = False
if xans + yans > 0:
	print('YES')
else:
	print('NO')


n = int(input())
pts = []
for i in range(n):
	(a, b) = [int(s) for s in input().strip().split()]
	pts.append((a, b))
p1 = pts[0]
p2 = pts[1]
if p1[0] == p2[0]:
	good = True
	for i in range(n):
		if not pts[i][0] == p1[0]:
			good = False
			break
	if good:
		print('YES')
	else:
		print('NO')
else:
	slope = (p1[1] - p2[1]) / (p1[0] - p2[0])
	k = p1[1] - p1[0] * slope
	good = True
	for i in range(n):
		if not abs(pts[i][0] * slope + k - pts[i][1]) < 1e-05:
			good = False
			break
	if good and slope == 0:
		print('YES')
	else:
		print('NO')


import sys
n = int(input().strip())
(x1, y1) = (None, None)
xyList = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	xyList.append([x, y])
allXSame = True
allYSame = True
for (x, y) in xyList:
	if x1 is None and y1 is None:
		(x1, y1) = (x, y)
	else:
		if x != x1:
			allXSame = False
		if y != y1:
			allYSame = False
print('YES' if allXSame or allYSame else 'NO')


import sys
n = int(input().strip())
points = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	points.append([x, y])
xs = [i[0] for i in points]
ys = [i[1] for i in points]
if len(list(set(xs))) == 1 or len(list(set(ys))) == 1:
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
vertical = True
horizontal = True
(x1, y1) = input().strip().split(' ')
(x1, y1) = [int(x1), int(y1)]
for a0 in range(n - 1):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	vertical = True if vertical and x == x1 else False
	horizontal = True if horizontal and y == y1 else False
if vertical or horizontal:
	print('YES')
else:
	print('NO')


import sys
x_line = True
y_line = True
x_prev = 0
y_prev = 0
n = int(input().strip())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	if a0 != 0:
		if x_line and x_prev != x:
			x_line = False
		if y_line and y_prev != y:
			y_line = False
	(x_prev, y_prev) = (x, y)
print('YES' if x_line or y_line else 'NO')


import sys
n = int(input().strip())
points = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	points.append((x, y))
vertical = True
horizontal = True
for i in range(len(points) - 1):
	if points[i][0] == points[i + 1][0]:
		vertical &= True
	elif points[i][0] != points[i + 1][0]:
		vertical &= False
	if points[i][1] == points[i + 1][1]:
		horizontal &= True
	elif points[i][1] != points[i + 1][1]:
		horizontal &= False
asnwer = 'YES' if vertical or horizontal else 'NO'
print(asnwer)


N = int(input())
(a, b) = map(int, input().strip().split())
(f, g) = (True, True)
for n in range(N - 1):
	(x, y) = map(int, input().strip().split())
	if a != x:
		f = False
	if b != y:
		g = False
	(a, b) = (x, y)
if f or g:
	print('YES')
else:
	print('NO')


import sys
is_vertical = True
is_horizontal = True
x_0 = 0
y_0 = 0
n = int(input().strip())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	if a0 == 0:
		x_0 = x
		y_0 = y
	if x != x_0:
		is_horizontal = False
	if y != y_0:
		is_vertical = False
if is_vertical or is_horizontal:
	print('YES')
else:
	print('NO')


import sys
xPoints = set()
yPoints = set()
n = int(input().strip())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	xPoints.add(x)
	yPoints.add(y)
if len(xPoints) == 1 or len(yPoints) == 1:
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
xs = set()
ys = set()
result = 'NO'
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	xs.add(x)
	ys.add(y)
if len(xs) == 1 or len(ys) == 1:
	result = 'YES'
print(result)


import sys
n = int(input().strip())
s_x = 1
s_y = 1
li_x = []
li_y = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	li_x.append(x)
	li_y.append(y)
for i in range(1, n):
	if li_x[i] != li_x[i - 1]:
		s_x = 0
	if li_y[i] != li_y[i - 1]:
		s_y = 0
if s_y == 1 or s_x == 1:
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
isOnHorizontal = True
isOnVertical = True
xs = []
ys = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	xs.append(x)
	ys.append(y)
xVert = xs[0]
for i in range(1, len(xs)):
	if xs[i] != xVert:
		isOnVertical = False
		break
yHori = ys[0]
for i in range(1, len(ys)):
	if ys[i] != yHori:
		isOnHorizontal = False
		break
if isOnVertical or isOnHorizontal:
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
x_list = []
y_list = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	x_list.append(x)
	y_list.append(y)
is_same_line = 'NO'
for l in [x_list, y_list]:
	if sum(l) / len(l) == l[0]:
		is_same_line = 'YES'
print(is_same_line)


import sys
n = int(input().strip())
(p_x, p_y) = (None, None)
status = ''
(px, py) = input().strip().split(' ')
(px, py) = [int(px), int(py)]
horiz = None
for a0 in range(n - 1):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	if horiz is None:
		if x == px:
			horiz = True
		elif y == py:
			horiz = False
		else:
			status = 'NO'
			break
	elif horiz and x != px or (not horiz and y != py):
		status = 'NO'
		break
if status == '':
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
l = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	l.append([x, y])
if not any([l[i][0] - l[0][0] for i in range(n)]) or not any([l[i][1] - l[0][1] for i in range(n)]):
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
points = list()
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	points.append((x, y))
if all([points[0][0] == p[0] for p in points]) or all([points[0][1] == p[1] for p in points]):
	print('YES')
else:
	print('NO')


import sys
a = 0
b = 0
i = 0
c = 0
n = int(input().strip())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	if i == 0:
		a = x
		b = y
		i += 1
	if a == x or b == y:
		c += 1
if c == n:
	print('YES')
else:
	print('NO')


import sys

def same_line(lst):
	xval = lst[0][0]
	yval = lst[0][1]
	xboo = True
	yboo = True
	for pt in lst:
		xboo = xboo and pt[0] == xval
		yboo = yboo and pt[1] == yval
	return xboo or yboo
lst = []
n = int(input().strip())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	lst.append((x, y))
if same_line(lst):
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
l = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	l.append([x, y])
flag1 = 1
flag2 = 1
for i in range(n - 1):
	if l[i][0] != l[i + 1][0]:
		flag1 = 0
	if l[i][1] != l[i + 1][1]:
		flag2 = 0
if flag1 == 1 or flag2 == 1:
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
countx = {}
county = {}
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	countx[x] = 1
	county[y] = 1
if len(countx) > 1 and len(county) > 1:
	print('NO')
else:
	print('YES')


import sys
_x = None
_y = None
vertical_line = True
horizontal_line = True
same_line = True
n = int(input().strip())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	if not _x or not _y:
		(_x, _y) = (x, y)
	if _x != x and _y != y:
		same_line = False
	elif x != x and horizontal_line:
		vertical_line = False
	elif y != y and vertical_line:
		horizontal_line = False
if same_line:
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
(x1, y1) = (-11, -11)
count1 = 0
count2 = 0
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	if x1 == -11 and y1 == -11:
		x1 = x
		y1 = y
		count1 += 1
		count2 += 1
	else:
		if x1 == x:
			count1 += 1
		if y1 == y:
			count2 += 1
if count1 == n or count2 == n:
	print('YES')
else:
	print('NO')


n = int(input())
a = [0 for i in range(n)]
b = [0 for i in range(n)]
for i in range(n):
	temp = [int(j) for j in input().split()]
	a[i] = temp[0]
	b[i] = temp[1]
a = set(a)
b = set(b)
if len(a) == 1 and len(b) == 1:
	print('NO')
elif len(a) == 1 or len(b) == 1:
	print('YES')
else:
	print('NO')


import sys
xpoints = []
ypoints = []
n = int(input().strip())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	xpoints.append(x)
	ypoints.append(y)
xlen = len(set(xpoints))
ylen = len(set(ypoints))
if xlen == 1 or ylen == 1:
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
array = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	array.append((x, y))
hori = array[0][0]
verti = array[0][1]
flag = 0
for i in range(len(array)):
	if hori != array[i][0]:
		flag += 1
		break
for i in range(len(array)):
	if verti != array[i][1]:
		if flag == 1:
			print('NO')
			flag += 1
			break
if flag <= 1:
	print('YES')


n = int(input())
x = []
y = []
for i in range(n):
	(xi, yi) = map(int, input().split())
	x.append(xi)
	y.append(yi)
if len(set(x)) == 1:
	print('YES')
elif len(set(y)) == 1:
	print('YES')
else:
	print('NO')


n = int(input())
l = []
cx = 0
cy = 0
for i in range(n):
	(x, y) = input().split(' ')
	l.append([int(x), int(y)])
tx = l[0][0]
ty = l[0][1]
for i in range(n):
	if tx != l[i][0]:
		cx = 1
for i in range(n):
	if ty != l[i][1]:
		cy = 1
if cx == 1 and cy == 1:
	print('NO')
else:
	print('YES')


import sys
xsame = True
ysame = True
n = int(input().strip())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	if a0 == 0:
		allx = x
		ally = y
	if a0 > 0:
		if allx != x:
			xsame = False
		if ally != y:
			ysame = False
if not xsame and (not ysame):
	print('NO')
else:
	print('YES')


import sys
n = int(input().strip())
points = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	points.append([x, y])
(vertical, horizontal) = (True, True)
for (index, point) in enumerate(points):
	if index == 0:
		(last_x, last_y) = (point[0], point[1])
	else:
		if last_x != point[0]:
			horizontal = False
		if last_y != point[1]:
			vertical = False
		if horizontal is False and vertical is False:
			break
print('YES' if horizontal or vertical else 'NO')


import sys
currentX = -100
currentY = -100
isGood = 'YES'
n = int(input().strip())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	if currentX == -100 or currentY == -100:
		currentX = x
		currentY = y
	elif (x > currentX or x < currentX) and (y > currentY or y < currentY):
		isGood = 'NO'
print(isGood)


import sys
x1 = []
y1 = []
n = int(input().strip())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	x1.append(int(x))
	y1.append(int(y))
if sum(x1) == x1[0] * n or sum(y1) == y1[0] * n:
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
(x0, y0) = input().strip().split(' ')
(x0, y0) = [int(x0), int(y0)]
f = 'xy'
f2 = 1
for a0 in range(n - 1):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	if f == 'x':
		if x != x0:
			f2 = 0
			break
	elif f == 'y':
		if y != y0:
			f2 = 0
			break
	elif f == 'xy':
		if x != x0 and y != y0:
			f2 = 0
			break
		elif x != x0:
			f = 'y'
		elif y != y0:
			f = 'x'
if f2:
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
X = [0] * n
Y = [0] * n
k = 0
for i in range(n):
	(x, y) = input().strip().split(' ')
	(X[i], Y[i]) = [int(x), int(y)]
if max(X) == min(X) or max(Y) == min(Y):
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
vx = []
vy = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	vx.append(x)
	vy.append(y)
resx = resy = 'YES'
for i in range(1, n):
	if vx[i - 1] != vx[i]:
		resx = 'NO'
	if vy[i - 1] != vy[i]:
		resy = 'NO'
if resx == 'YES' or resy == 'YES':
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
lst = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	lst.append((x, y))
(ans, c, ind) = (True, 0, 0)
if lst[0][0] == lst[1][0]:
	(c, ind) = (lst[0][0], 0)
elif lst[0][1] == lst[1][1]:
	(c, ind) = (lst[0][1], 1)
else:
	ans = False
for i in range(2, len(lst)):
	if lst[i][ind] != c:
		ans = False
if ans:
	print('YES')
else:
	print('NO')


import sys
x1 = y1 = 0
n = int(input().strip())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	x1 += x
	y1 += y
if x1 / n == x or y1 / n == y:
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
xs = set()
ys = set()
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	xs.add(x)
	ys.add(y)
if len(xs) == 1 or len(ys) == 1:
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
line_x = []
line_y = []
x_line = True
y_line = True
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	line_x.append(x)
	line_y.append(y)
for i in range(0, n - 1):
	if line_x[i] != line_x[i + 1]:
		x_line = False
	if line_y[i] != line_y[i + 1]:
		y_line = False
if x_line or y_line:
	print('YES')
else:
	print('NO')


import sys
points = []
n = int(input().strip())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = (int(x), int(y))
	points.append((x, y))

def line_or_not(points):
	(vertical, horizontal) = (True, True)
	for point in points:
		if point[0] != points[0][0]:
			vertical = False
		if point[1] != points[0][1]:
			horizontal = False
	if vertical or horizontal:
		return 'YES'
	else:
		return 'NO'
print(line_or_not(points))


xs = []
ys = []
n = int(input().strip())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	xs.append(x)
	ys.append(y)
if len(set(xs)) == 1:
	print('YES')
elif len(set(ys)) == 1:
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
vert = True
horz = True
points = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	points.append((x, y))
h = points[0][0]
v = points[0][1]
for i in range(1, len(points)):
	point = points[i]
	if point[0] != h:
		horz = False
	if point[1] != v:
		vert = False
if not horz and (not vert):
	print('NO')
else:
	print('YES')


def pendiente(x1, y1, x2, y2):
	if x2 - x1 == 0:
		return 0
	else:
		return (y2 - y1) / (x2 - x1)
n = int(input().strip())
(x1, y1) = map(int, input().split())
aux = True
for i in range(n - 1):
	(x2, y2) = map(int, input().split())
	if pendiente(x1, y1, x2, y2) != 0:
		print('NO')
		aux = False
		break
	(x1, y1) = (x2, y2)
if aux:
	print('YES')


import sys
n = int(input().strip())
xpointsall = []
ypointsall = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	xpointsall.append(x)
	ypointsall.append(y)
flag = None
if all((x == xpointsall[0] for x in xpointsall)):
	flag = 'YES'
elif all((y == ypointsall[0] for y in ypointsall)):
	flag = 'YES'
else:
	flag = 'NO'
print(flag)


(i, n, f, r) = (1, int(input()), [1, 1], ['NO', 'YES'])
(x1, y1) = map(int, input().split())
while i < n and (f[0] or f[1]):
	i += 1
	(x, y) = map(int, input().split())
	f[0] &= x == x1
	f[1] &= y == y1
print(r[f[0] or f[1]])


import sys
n = int(input().strip())
a = [0] * (n - 1)
b = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = (int(x), int(y))
	b.append((x, y))
c = 0
for i in range(n - 1):
	if b[i][0] != b[i + 1][0]:
		a[i] = (b[i + 1][1] - b[i][1]) / (b[i + 1][0] - b[i][0])
	else:
		a[i] = 'o'
f = 1
for i in range(len(a)):
	if a[i] != 'o' and a[i] != 0:
		f = 0
		break
if f == 0:
	print('NO')
else:
	print('YES')


import sys
xCoord = []
yCoord = []
n = int(input().strip())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	xCoord.append(x)
	yCoord.append(y)
if xCoord[0] - xCoord[1] == 0:
	straightLine = True
	for i in range(2, len(xCoord)):
		if xCoord[i] != xCoord[0]:
			straightLine = False
	if straightLine == True:
		print('YES')
	else:
		print('NO')
else:
	straightLine = True
	slope = (yCoord[1] - yCoord[0]) / (xCoord[1] - yCoord[0])
	yInt = yCoord[0] - slope * xCoord[0]
	for i in range(2, len(xCoord)):
		if yCoord[i] != slope * xCoord[i] + yInt:
			straightLine = False
			break
	if straightLine == True and slope == 0:
		print('YES')
	else:
		print('NO')


import sys
n = int(input().strip())
x = []
y = []
for a0 in range(n):
	s = [int(i) for i in input().strip().split(' ')]
	x.append(s[0])
	y.append(s[1])
if len(set(x)) == 1 or len(set(y)) == 1:
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
(x0, y0) = input().strip().split(' ')
(x0, y0) = [int(x0), int(y0)]
xt = yt = True
for a0 in range(n - 1):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	if x != x0:
		xt = False
	if y != y0:
		yt = False
if xt or yt:
	print('YES')
else:
	print('NO')


import sys
T = int(sys.stdin.readline())
P = [list(map(int, sys.stdin.readline().split())) for _ in range(T)]
(X, Y) = list(zip(*P))
print('YES' if len(set(X)) == 1 or len(set(Y)) == 1 else 'NO')


import sys
n = int(input().strip())
(X, Y) = ([], [])
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	X.append(x)
	Y.append(y)
if all([x == X[0] for x in X]) | all([y == Y[0] for y in Y]):
	print('YES')
else:
	print('NO')


import sys
points = []
n = int(input().strip())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	points.append([int(x), int(y)])
vertical = True
horizontal = True
for point in points:
	if point[0] != points[0][0]:
		vertical = False
	if point[1] != points[0][1]:
		horizontal = False
if vertical == False and horizontal == False:
	print('NO')
else:
	print('YES')


import sys
all_x = []
all_y = []
n = int(input().strip())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	g = [int(x), int(y)]
	all_x.append(g[0])
	all_y.append(g[1])

def checkSlp(lst):
	count = 0
	for i in range(n):
		if lst[i] == lst[i + 1]:
			count = count + 1
			if count + 1 == n:
				return True
		else:
			break
	return False
if checkSlp(all_x) or checkSlp(all_y):
	print('YES')
else:
	print('NO')


def main():
	N = int(input().strip())
	points = []
	for _ in range(N):
		points.append([float(x) for x in input().strip().split(' ')])
	if len(set((x[0] for x in points))) == 1:
		return 'YES'
	if len(set((x[1] for x in points))) == 1:
		return 'YES'
	return 'NO'
print(main())


N = eval(input())
(k, g, z, l) = (0, 0, [], [])
for k in range(N):
	poi = input().split(' ')
	z.append(int(poi[0]))
	l.append(int(poi[1]))
k = 0
for j in range(1, len(z)):
	if z[j] == z[0]:
		k = k + 1
for i in range(1, len(l)):
	if l[i] == l[0]:
		g = g + 1
if g == len(l) - 1 or k == len(l) - 1:
	print('YES')
else:
	print('NO')


sx = set()
sy = set()
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	sx.add(x)
	sy.add(y)
print('YES' if len(sx) == 1 or len(sy) == 1 else 'NO')


(X, Y) = ([], [])
for _ in range(int(input())):
	(x, y) = map(int, input().strip().split())
	if x not in X:
		X.append(x)
	if y not in Y:
		Y.append(y)
print('YES' if len(X) == 1 or len(Y) == 1 else 'NO')


import sys
n = int(input().strip())
(x, y) = input().strip().split(' ')
x0 = int(x)
y0 = int(y)
is_line = ''
for a0 in range(n - 1):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	if x == x0 or y == y0:
		is_line = 'YES'
		continue
	else:
		is_line = 'NO'
		break
print(is_line)


import sys
xarr = []
yarr = []
n = int(input().strip())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	xarr.append(x)
	yarr.append(y)
xflag = 0
for number in range(1, len(xarr)):
	if xarr[0] != xarr[number]:
		xflag = 1
yflag = 0
for number in range(1, len(yarr)):
	if yarr[0] != yarr[number]:
		yflag = 1
if xflag == 0 or yflag == 0:
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
l = []
r = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	l.append(x)
	r.append(y)
flag1 = 0
flag2 = 0
a = l[0]
b = r[0]
for i in range(n):
	if l[i] != a or flag1 == 1:
		flag1 = 1
	if r[i] != b or flag2 == 1:
		flag2 = 1
if flag1 == 0 or flag2 == 0:
	print('YES')
else:
	print('NO')


n = int(input())
k = []
m = []
for a0 in range(n):
	x = [int(i) for i in input().split(' ')]
	k.append(x[0])
	m.append(x[1])
if len(set(k)) == 1 or len(set(m)) == 1:
	if len(set(k)) != len(set(m)):
		print('YES')
	else:
		print('NO')
else:
	print('NO')


import sys
pts = []
n = int(input().strip())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	pts.append([x, y])
eqx = pts[0][0]
eqxc = True
eqy = pts[0][1]
eqyc = True
for c in range(n):
	if eqxc:
		if eqx == pts[c][0]:
			pass
		else:
			eqxc = False
	if eqyc:
		if eqy == pts[c][1]:
			pass
		else:
			eqyc = False
if eqxc or eqyc:
	print('YES')
else:
	print('NO')


t = int(input())
x = []
y = []
while t > 0:
	t -= 1
	(x1, y1) = list(map(int, input().split()))
	x.append(x1)
	y.append(y1)
i = 0
while i < len(x) - 1 and x[i] == x[i + 1]:
	i += 1
if i == len(x) - 1:
	print('YES')
else:
	i = 0
	while i < len(y) - 1 and y[i] == y[i + 1]:
		i += 1
	if i == len(y) - 1:
		print('YES')
	else:
		print('NO')


import sys
Bool_x = True
Bool_y = True
X = 0
Y = 0
n = int(input().strip())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	if a0 == 0:
		X = x
		Y = y
	if x != X:
		Bool_x = False
	if y != Y:
		Bool_y = False
if Bool_x == True or Bool_y == True:
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
xx = 0
yy = 0
xcounter = 0
ycounter = 0
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	if a0 == 0:
		xcounter = 1
		ycounter = 1
		xx = x
		yy = y
	else:
		if x == xx:
			xcounter += 1
		if y == yy:
			ycounter += 1
if (xcounter == n) | (ycounter == n):
	print('YES')
else:
	print('NO')


import sys
lista_x = []
lista_y = []
n = int(input().strip())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	lista_x.append(x)
	lista_y.append(y)
if len(set(lista_x)) == 1 or len(set(lista_y)) == 1:
	print('YES')
else:
	print('NO')


import sys
n = int(input().strip())
points = []
for a0 in range(n):
	point = input().strip().split(' ')
	(x, y) = [int(z) for z in point]
	points.append(point)
x = points[0][0]
y = points[0][1]
horizontal = True
vertical = True
for point in points:
	if point[0] != x:
		horizontal = False
	if point[1] != y:
		vertical = False
if horizontal == False and vertical == False:
	print('NO')
else:
	print('YES')


import cmath
import sys
n = int(input())
(x0, y0) = [int(x) for x in input().split()]
ps = []
for _ in range(1, n):
	(x, y) = [int(x) for x in input().split()]
	ps.append(complex(x - x0, y - y0))
for i in range(n - 1):
	if not (ps[i].imag == 0 or ps[i].real == 0):
		print('NO')
		sys.exit()
print('YES')


import sys
n = int(input().strip())
arr = []
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	m = [int(x), int(y)]
	arr.append(m)
d = [arr[i][0] for i in range(n)]
p = [arr[i][1] for i in range(n)]
if len(list(set(d))) == 1 or len(list(set(p))) == 1:
	print('YES')
else:
	print('NO')


(xs, ys) = ([], [])
for _ in range(int(input())):
	(x, y) = [int(a) for a in input().split()]
	xs.append(x)
	ys.append(y)
if len(set(xs)) == 1 or len(set(ys)) == 1:
	print('YES')
else:
	print('NO')


import sys
X = []
Y = []
count_x = 0
count_y = 0
n = int(input().strip())
for a0 in range(n):
	(x, y) = input().strip().split(' ')
	(x, y) = [int(x), int(y)]
	X.append(x)
	Y.append(y)
for i in range(1, len(X)):
	if X[i] != X[0]:
		count_x = count_x + 1
		break
for j in range(1, len(Y)):
	if Y[j] != Y[0]:
		count_y = count_y + 1
		break
if count_x == 0 and count_y == 0 or (count_x == 0 and count_y != 0) or (count_x != 0 and count_y == 0):
	print('YES')
else:
	print('NO')