After the war, the supersonic rocket became the most common public transportation.

Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has $n$ power sources, and the second one has $m$ power sources. A power source can be described as a point $(x_i, y_i)$ on a 2-D plane. All points in each engine are different.

You can manipulate each engine separately. There are two operations that you can do with each engine. You can do each operation as many times as you want. For every power source as a whole in that engine: $(x_i, y_i)$ becomes $(x_i+a, y_i+b)$, $a$ and $b$ can be any real numbers. In other words, all power sources will be shifted. For every power source as a whole in that engine: $(x_i, y_i)$ becomes $(x_i \cos \theta - y_i \sin \theta, x_i \sin \theta + y_i \cos \theta)$, $\theta$ can be any real number. In other words, all power sources will be rotated.

The engines work as follows: after the two engines are powered, their power sources are being combined (here power sources of different engines may coincide). If two power sources $A(x_a, y_a)$ and $B(x_b, y_b)$ exist, then for all real number $k$ that $0 \lt k \lt 1$, a new power source will be created $C_k(kx_a+(1-k)x_b,ky_a+(1-k)y_b)$. Then, this procedure will be repeated again with all new and old power sources. After that, the "power field" from all power sources will be generated (can be considered as an infinite set of all power sources occurred).

A supersonic rocket is "safe" if and only if after you manipulate the engines, destroying any power source and then power the engine, the power field generated won't be changed (comparing to the situation where no power source erased). Two power fields are considered the same if and only if any power source in one field belongs to the other one as well.

Given a supersonic rocket, check whether it is safe or not.


-----Input-----

The first line contains two integers $n$, $m$ ($3 \le n, m \le 10^5$) — the number of power sources in each engine.

Each of the next $n$ lines contains two integers $x_i$ and $y_i$ ($0\leq x_i, y_i\leq 10^8$) — the coordinates of the $i$-th power source in the first engine.

Each of the next $m$ lines contains two integers $x_i$ and $y_i$ ($0\leq x_i, y_i\leq 10^8$) — the coordinates of the $i$-th power source in the second engine.

It is guaranteed that there are no two or more power sources that are located in the same point in each engine.


-----Output-----

Print "YES" if the supersonic rocket is safe, otherwise "NO".

You can print each letter in an arbitrary case (upper or lower).


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

Output
YES

Input
3 4
0 0
0 2
2 0
0 2
2 2
2 0
0 0

Output
NO



-----Note-----

The first sample: [Image] Those near pairs of blue and orange points actually coincide. 

First, manipulate the first engine: use the second operation with $\theta = \pi$ (to rotate all power sources $180$ degrees).

The power sources in the first engine become $(0, 0)$, $(0, -2)$, and $(-2, 0)$. [Image] 

Second, manipulate the second engine: use the first operation with $a = b = -2$.

The power sources in the second engine become $(-2, 0)$, $(0, 0)$, $(0, -2)$, and $(-1, -1)$. [Image] 

You can examine that destroying any point, the power field formed by the two engines are always the solid triangle $(0, 0)$, $(-2, 0)$, $(0, -2)$.

In the second sample, no matter how you manipulate the engines, there always exists a power source in the second engine that power field will shrink if you destroy it.

Source: codeforces | Difficulty: VERY_HARD
Tags: Geometry

String algorithms


Solutions:
import sys

def orientation(p1, p2, p3):
	return (p2[0] - p1[0]) * (p3[1] - p1[1]) - (p2[1] - p1[1]) * (p3[0] - p1[0])

def dot(p1, p2, p3, p4):
	return (p2[0] - p1[0]) * (p4[0] - p3[0]) + (p2[1] - p1[1]) * (p4[1] - p3[1])

def theta(p1, p2):
	dx = p2[0] - p1[0]
	dy = p2[1] - p1[1]
	if abs(dx) < 0.1 and abs(dy) < 0.1:
		t = 0
	else:
		t = dy / (abs(dx) + abs(dy))
		if abs(t) < 0.1 ** 10:
			t = 0
	if dx < 0:
		t = 2 - t
	elif dy < 0:
		t = 4 + t
	return t * 90

def dist_sq(p1, p2):
	return (p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1])

def chull(points):
	pi = [x for x in range(len(points))]
	min_y = points[0][1]
	min_x = points[0][0]
	min_ind = 0
	for i in range(len(points)):
		if points[i][1] < min_y or (points[i][1] == min_y and points[i][0] < min_x):
			min_y = points[i][1]
			min_x = points[i][0]
			min_ind = i
	pi[0] = min_ind
	pi[min_ind] = 0
	th = [theta(points[pi[0]], points[x]) for x in range(len(points))]
	pi.sort(key=lambda x: th[x])
	unique = [pi[0], pi[1]]
	for i in range(2, len(pi)):
		if th[pi[i]] != th[unique[-1]]:
			unique.append(pi[i])
		elif dist_sq(points[pi[0]], points[unique[-1]]) < dist_sq(points[pi[0]], points[pi[i]]):
			unique[-1] = pi[i]
	pi = unique
	stack = []
	for i in range(min(len(pi), 3)):
		stack.append(points[pi[i]])
	if len(stack) < 3:
		return stack
	for i in range(3, len(pi)):
		while len(stack) >= 2:
			o = orientation(stack[-2], stack[-1], points[pi[i]])
			if o > 0:
				stack.append(points[pi[i]])
				break
			elif o < 0:
				stack.pop()
			elif dist_sq(stack[-2], stack[-1]) < dist_sq(stack[-2], points[pi[i]]):
				stack.pop()
			else:
				break
	return stack

def z_func(s):
	(slen, l, r) = (len(s), 0, 0)
	z = [0] * slen
	z[0] = slen
	for i in range(1, slen):
		if i <= r:
			z[i] = min(r - i + 1, z[i - l])
		while i + z[i] < slen and s[z[i]] == s[i + z[i]]:
			z[i] += 1
		if i + z[i] - 1 > r:
			(l, r) = (i, i + z[i] - 1)
	return z
(n, m) = map(int, sys.stdin.readline().strip().split())
a = []
for _ in range(n):
	(x, y) = map(int, sys.stdin.readline().strip().split())
	a.append((x, y))
b = []
for _ in range(m):
	(x, y) = map(int, sys.stdin.readline().strip().split())
	b.append((x, y))
ah = chull(a)
bh = chull(b)
if len(ah) == len(bh):
	if len(ah) == 2:
		if dist_sq(ah[0], ah[1]) == dist_sq(bh[0], bh[1]):
			print('YES')
		else:
			print('NO')
	else:
		da = []
		for i in range(len(ah)):
			dot_a = dot(ah[i - 2], ah[i - 1], ah[i - 1], ah[i])
			da.append((dist_sq(ah[i], ah[i - 1]), dot_a))
		db = []
		for i in range(len(bh)):
			dot_b = dot(bh[i - 2], bh[i - 1], bh[i - 1], bh[i])
			db.append((dist_sq(bh[i], bh[i - 1]), dot_b))
		l = r = 0
		daab = []
		daab.extend(db)
		daab.append(-1)
		daab.extend(da)
		daab.extend(da)
		zab = z_func(daab)
		found = False
		for i in range(len(db) + 1, len(daab) - len(db) + 1):
			if zab[i] == len(db):
				found = True
				break
		if found:
			print('YES')
		else:
			print('NO')
else:
	print('NO')