Inaka has a disc, the circumference of which is $n$ units. The circumference is equally divided by $n$ points numbered clockwise from $1$ to $n$, such that points $i$ and $i + 1$ ($1 \leq i < n$) are adjacent, and so are points $n$ and $1$.

There are $m$ straight segments on the disc, the endpoints of which are all among the aforementioned $n$ points.

Inaka wants to know if her image is rotationally symmetrical, i.e. if there is an integer $k$ ($1 \leq k < n$), such that if all segments are rotated clockwise around the center of the circle by $k$ units, the new image will be the same as the original one.


-----Input-----

The first line contains two space-separated integers $n$ and $m$ ($2 \leq n \leq 100\,000$, $1 \leq m \leq 200\,000$) — the number of points and the number of segments, respectively.

The $i$-th of the following $m$ lines contains two space-separated integers $a_i$ and $b_i$ ($1 \leq a_i, b_i \leq n$, $a_i \neq b_i$) that describe a segment connecting points $a_i$ and $b_i$.

It is guaranteed that no segments coincide.


-----Output-----

Output one line — "Yes" if the image is rotationally symmetrical, and "No" otherwise (both excluding quotation marks).

You can output each letter in any case (upper or lower).


-----Examples-----
Input
12 6
1 3
3 7
5 7
7 11
9 11
11 3

Output
Yes

Input
9 6
4 5
5 6
7 8
8 9
1 2
2 3

Output
Yes

Input
10 3
1 2
3 2
7 2

Output
No

Input
10 2
1 6
2 7

Output
Yes



-----Note-----

The first two examples are illustrated below. Both images become the same as their respective original ones after a clockwise rotation of $120$ degrees around the center.

 [Image]

Difficulty: HARD
Tags: String algorithms

Complete search
Skill types: Complete search

Starter code:

Solutions:
def check(k, g):
	for i in g:
		a = (i[0] + k) % n
		b = (i[1] + k) % n
		if not (min(a, b), max(a, b)) in g:
			return False
	return True
(n, m) = [int(i) for i in input().split()]
g = set()
for i in range(m):
	(a, b) = [int(i) for i in input().split()]
	a -= 1
	b -= 1
	g.add((min(a, b), max(a, b)))
for i in range(1, n):
	if n % i == 0:
		if not check(i, g):
			continue
		print('Yes')
		break
else:
	print('No')


from collections import defaultdict
import sys
(n, m) = [int(item) for item in sys.stdin.readline().strip().split()]
s = []
for line in sys.stdin.readlines():
	s.append([int(item) for item in line.strip().split()])
divs = []
for i in range(1, n):
	if n % i == 0:
		divs.append(i)

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isSubArray(A, B):
	(n, m) = (len(A), len(B))
	i = 0
	j = 0
	while i < n and j < m:
		if A[i] == B[j]:
			i += 1
			j += 1
			if j == m:
				return True
		else:
			i += 1
			j = 0
	return False

def check(a, v):
	new = [(x + v - 1) % n + 1 for x in a]
	return sorted(new) == sorted(a)

def get_value(a):
	if len(a) == 1:
		return -1
	p = len(a)
	for v in divs:
		if check(a, v):
			return v
	return -1

def solve():
	if n == 2:
		return True
	d = defaultdict(list)
	for (l, r) in s:
		d[min(abs(l - r), n - abs(l - r))].extend([l, r])
	verdict = True
	values = []
	for x in d:
		values.append(get_value(d[x]))
	if -1 in values:
		return False
	v = values[0]
	for x in values[1:]:
		v = v * x // gcd(v, x)
	if v < n:
		return True
	return False
sys.stdout.write('Yes' if solve() else 'No')


(n, m) = [int(x) for x in input().split()]
segs = set()
for i in range(m):
	segs.add(tuple(sorted((int(x) - 1 for x in input().split()))))
for i in range(1, n):
	if n % i != 0:
		continue
	j = 0
	for (a, b) in segs:
		if tuple(sorted(((a + i) % n, (b + i) % n))) not in segs:
			break
		j += 1
	if j == m:
		print('Yes')
		exit()
print('No')


import sys
import collections
(n, m) = map(int, input().split())
segs = set()
for _ in range(m):
	(start, end) = map(int, input().split())
	segs.add((start - 1, end - 1))

def get_divisors(n):
	divisors = []
	for i in range(1, n):
		if n % i == 0:
			divisors.append(i)
	return divisors
divisors = get_divisors(n)
for k in divisors:
	for (sega, segb) in segs:
		if ((sega + k) % n, (segb + k) % n) not in segs and ((segb + k) % n, (sega + k) % n) not in segs:
			break
	else:
		print('Yes')
		sys.exit()
print('No')


import sys
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def main():
	(n, m) = map(int, input().split())
	S = set()
	for i in range(m):
		(a, b) = map(int, input().split())
		(a, b) = (a - 1, b - 1)
		if a > b:
			(a, b) = (b, a)
		S.add((a, b))

	def make_divisors(n):
		divisors = []
		for i in range(1, int(n ** 0.5) + 1):
			if n % i == 0:
				divisors.append(i)
				if i != n // i:
					divisors.append(n // i)
		return divisors
	D = make_divisors(n)
	for d in D:
		if d == n:
			continue
		T = set()
		flag = True
		for (a, b) in S:
			na = (a + d) % n
			nb = (b + d) % n
			if na > nb:
				(na, nb) = (nb, na)
			if (na, nb) not in S:
				flag = False
				break
			T.add((na, nb))
		if not flag:
			continue
		for (a, b) in S:
			if (a, b) not in T:
				break
		else:
			print('Yes')
			exit()
	else:
		print('No')
main()


from sys import stdin, stdout
(n, m) = map(int, stdin.readline().split())
g = set()
for i in range(m):
	(a, b) = map(int, stdin.readline().split())
	a -= 1
	b -= 1
	g.add((min(a, b), max(a, b)))

def check(k):
	for i in g:
		a = (i[0] + k) % n
		b = (i[1] + k) % n
		if not (min(a, b), max(a, b)) in g:
			return False
	return True
for k in range(1, n):
	if n % k == 0:
		if not check(k):
			continue
		stdout.write('Yes')
		exit(0)
stdout.write('No')


import sys

def No():
	print('No')
	sys.exit()

def divi(n):
	res = [1]
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			if i != n // i:
				res.append(n // i)
	return res
(N, M) = map(int, input().split())
DN = divi(N)
dis = [set() for _ in range(N // 2 + 1)]
for i in range(M):
	(a, b) = map(lambda x: int(x) - 1, sys.stdin.readline().split())
	(fn, ln) = ((a - b) % N, (b - a) % N)
	if fn < ln:
		dis[fn].add(b)
	elif ln < fn:
		dis[ln].add(a)
	else:
		dis[fn].add(a)
		dis[fn].add(b)
for dn in DN:
	for D in dis:
		if not D:
			continue
		for d in D:
			if (d + dn) % N not in D:
				break
		else:
			continue
		break
	else:
		print('Yes')
		sys.exit()
No()


nz = [int(x) for x in input().split()]
edges = set()
divisors = set()
for x in range(0, nz[1]):
	uv = [y for y in input().split()]
	edges.add(uv[0] + ' ' + uv[1])
for x in range(1, nz[0]):
	if nz[0] % x == 0:
		divisors.add(x)
flag = 0
for y in divisors:
	flag = 0
	for x in edges:
		u = (int(x.split()[0]) + y) % nz[0]
		v = (int(x.split()[1]) + y) % nz[0]
		if u == 0:
			u = nz[0]
		if v == 0:
			v = nz[0]
		if str(u) + ' ' + str(v) not in edges:
			if str(v) + ' ' + str(u) not in edges:
				flag = 1
				break
	if flag == 0:
		print('Yes')
		break
if flag == 1:
	print('No')


from collections import defaultdict
import sys
(n, m) = [int(item) for item in sys.stdin.readline().strip().split()]
s = []
for _ in range(m):
	s.append(sorted([int(item) for item in sys.stdin.readline().strip().split()]))
rights = defaultdict(set)
for (l, r) in s:
	rights[l].add(r)
	rights[r].add(l)
divs = set()
for i in range(1, n):
	if n % i == 0:
		divs.add(i)

def solve():
	for v in divs:
		ok = True
		for (l, r) in s:
			ok &= (r + v - 1) % n + 1 in rights[(l + v - 1) % n + 1]
		if ok:
			return True
	return False
print('Yes' if solve() else 'No')


from __future__ import division, print_function
import os
import sys
from collections import Counter
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
else:
	_str = str
	str = lambda x=b'': x if type(x) is bytes else _str(x).encode()

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
mod_add = lambda x, y, m: x + y if x + y < m else x + y - m

def memodict(f):

	class memodict(dict):

		def __missing__(self, key):
			ret = self[key] = f(key)
			return ret
	return memodict().__getitem__

def pollard_rho(n):
	if n & 1 == 0:
		return 2
	if n % 3 == 0:
		return 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			prev = p
			p = p * p % n
			if p == 1:
				return gcd(prev - 1, n)
			if p == n - 1:
				break
		else:
			for i in range(2, n):
				(x, y) = (i, (i * i + 1) % n)
				f = gcd(abs(x - y), n)
				while f == 1:
					(x, y) = ((x * x + 1) % n, (y * y + 1) % n)
					y = (y * y + 1) % n
					f = gcd(abs(x - y), n)
				if f != n:
					return f
	return n

@memodict
def prime_factors(n):
	if n <= 1:
		return Counter()
	f = pollard_rho(n)
	return Counter([n]) if f == n else prime_factors(f) + prime_factors(n // f)

def main():
	(n, m) = map(int, input().split())
	p = [(0, 0)] * m
	for i in range(m):
		(x, y) = map(int, input().split())
		p[i] = (min(x - 1, y - 1), max(x - 1, y - 1))
	p.sort()
	for factor in prime_factors(n):
		factor = n // factor
		fp = [(0, 0)] * m
		for i in range(m):
			(x, y) = p[i]
			(x, y) = (mod_add(x, factor, n), mod_add(y, factor, n))
			fp[i] = (min(x, y), max(x, y))
		fp.sort()
		if p == fp:
			print('Yes')
			return
	print('No')
	return
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._buffer = BytesIO()
		self._fd = file.fileno()
		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):
		if self._buffer.tell():
			return self._buffer.read()
		return os.read(self._fd, os.fstat(self._fd).st_size)

	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 ostream:

	def __lshift__(self, a):
		if a is endl:
			sys.stdout.write(b'\n')
			sys.stdout.flush()
		else:
			sys.stdout.write(str(a))
		return self

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', b' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', b'\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
(cout, endl) = (ostream(), object())
readline = sys.stdin.readline
readlist = lambda var=int: [var(n) for n in readline().split()]
input = lambda : readline().rstrip(b'\r\n')
main()


from collections import defaultdict, deque
(n, m) = [int(item) for item in input().split()]
s = []
for _ in range(m):
	s.append([int(item) for item in input().split()])
divs = []
for i in range(1, n):
	if n % i == 0:
		divs.append(i)

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isSubArray(A, B):
	(n, m) = (len(A), len(B))
	i = 0
	j = 0
	while i < n and j < m:
		if A[i] == B[j]:
			i += 1
			j += 1
			if j == m:
				return True
		else:
			i += 1
			j = 0
	return False

def check(a, v):
	new = [(x + v - 1) % n + 1 for x in a]
	return sorted(new) == sorted(a)

def get_value(a):
	if len(a) == 1:
		return -1
	p = len(a)
	for v in divs:
		if check(a, v):
			return v
	return -1

def solve():
	if n == 2:
		return True
	d = defaultdict(list)
	for (l, r) in s:
		d[min(abs(l - r), n - abs(l - r))].extend([l, r])
	verdict = True
	values = []
	for x in d:
		values.append(get_value(d[x]))
	if -1 in values:
		return False
	v = values[0]
	for x in values[1:]:
		v = v * x // gcd(v, x)
	if v < n:
		return True
	return False
print('Yes' if solve() else 'No')


def divs(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	if int(n ** 0.5) ** 2 == n:
		res.pop()
	return res

def main():
	(n, m) = map(int, input().split())
	angles = [set() for i in range(n)]
	for i in range(m):
		(a, b) = map(int, input().split())
		a -= 1
		b -= 1
		a1 = b - a
		if a1 < 0:
			a1 += n
		angles[a].add(a1)
		b1 = a - b
		if b1 < 0:
			b1 += n
		angles[b].add(b1)
	d = divs(n)
	for di in d:
		if di == n:
			continue
		flag = 1
		for i in range(n):
			if angles[i] != angles[(i + di) % n]:
				flag = 0
				break
		if flag == 1:
			print('Yes')
			return 0
	print('No')
	return 0
main()


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve():
	(n, m) = sep()
	div = []
	for i in range(1, floor(n ** 0.5) + 1):
		if n % i == 0:
			div.append(i)
			if n // i != n and n // i != i:
				div.append(n // i)
	graph = set()
	for i in range(m):
		(a, b) = sep()
		a -= 1
		b -= 1
		(a, b) = (min(a, b), max(a, b))
		graph.add((a, b))
	for i in range(len(div)):
		f = True
		for j in graph:
			(a, b) = ((j[0] + div[i]) % n, (j[1] + div[i]) % n)
			(a, b) = (min(a, b), max(a, b))
			if (a, b) not in graph:
				f = False
				break
		if f:
			print('Yes')
			return
	print('No')
testcase(1)


(n, m) = map(int, input().split())
arr = [set() for i in range(n)]
for i in range(m):
	(a, b) = map(int, input().split())
	a -= 1
	b -= 1
	f = b - a
	if f < 0:
		f += n
	arr[a].add(f)
	f = a - b
	if f < 0:
		f += n
	arr[b].add(f)
lst = [1]
for i in range(2, int(n ** 0.5) + 1):
	if n % i == 0:
		lst.append(i)
		lst.append(n // i)
flag = 0
for el in lst:
	for i in range(n):
		next = (i + el) % n
		if arr[i] != arr[next]:
			flag = 1
			break
	if flag == 0:
		print('Yes')
		exit(0)
	flag = 0
print('No')


def main():
	from sys import stdin, stdout

	def read():
		return stdin.readline().rstrip('\n')

	def read_array(sep=None, maxsplit=-1):
		return read().split(sep, maxsplit)

	def read_int():
		return int(read())

	def read_int_array(sep=None, maxsplit=-1):
		return [int(a) for a in read_array(sep, maxsplit)]

	def write(*args, **kwargs):
		sep = kwargs.get('sep', ' ')
		end = kwargs.get('end', '\n')
		stdout.write(sep.join((str(a) for a in args)) + end)

	def write_array(array, **kwargs):
		sep = kwargs.get('sep', ' ')
		end = kwargs.get('end', '\n')
		stdout.write(sep.join((str(a) for a in array)) + end)
	(n, m) = read_int_array()
	lines = set()
	for _ in range(m):
		(a, b) = read_int_array()
		lines.add((min(a, b) - 1, max(a, b) - 1))
	for i in range(1, n):
		if n % i == 0:
			for (a, b) in lines:
				(a, b) = ((a + i) % n, (b + i) % n)
				if a > b:
					(a, b) = (b, a)
				if (a, b) not in lines:
					break
			else:
				write('Yes')
				return
	write('No')
main()


cin = lambda : [*map(int, input().split())]
(n, m) = cin()
se = set()
x = [tuple(sorted(cin())) for _ in range(m)]
for e in x:
	se.add((e[0] - 1, e[1] - 1))
for i in range(1, n):
	if n % i != 0:
		continue
	ok = True
	for e in se:
		if tuple(sorted([(e[0] + i) % n, (e[1] + i) % n])) not in se:
			ok = False
			break
	if ok:
		print('Yes')
		exit(0)
print('No')


def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(a, b):
	return a * b // gcd(a, b)
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
kk = lambda : map(int, input().split())
k2 = lambda : map(lambda x: int(x) - 1, input().split())
ll = lambda : list(kk())
(n, m) = kk()
nodes = [[] for _ in range(n)]
for _ in range(m):
	(n1, n2) = k2()
	nodes[n1].append((n2 - n1) % n)
	nodes[n2].append((n1 - n2) % n)
seen = {}
nextv = 0
lists = []
(node2, used) = ([0] * n, [False] * n)
for (i, no) in enumerate(nodes):
	t = tuple(sorted(no))
	if not t in seen:
		(seen[t], nextv) = (nextv, nextv + 1)
		lists.append([])
	lists[seen[t]].append(i)
	node2[i] = seen[t]
lists.sort(key=len)
valids = set()
for i in range(nextv - 1):
	cl = lists[i]
	n0 = cl[0]
	continueing = True
	while continueing:
		continueing = False
		for j in range(1, len(cl)):
			if used[cl[j]]:
				continue
			dist = cl[j] - n0
			if n % dist != 0:
				continue
			for k in range(n0, n + n0, dist):
				k = k % n
				if used[k] or node2[k] != node2[n0]:
					break
			else:
				valids.add(dist)
				for k in range(n0, n + n0, dist):
					k = k % n
					used[k] = True
				cl = [x for x in cl if (x - n0) % dist != 0]
				n0 = cl[0] if cl else 0
				continueing = True
				break
	if len(cl) > 0:
		print('NO')
		exit()
lc = 1
for value in valids:
	lc = lcm(lc, value)
print('YES' if lc < n else 'NO')


(n, m) = map(int, input().split())
a = []
for i in range(m):
	a.append(list(map(int, input().split())))
	if a[i][0] > a[i][1]:
		(a[i][0], a[i][1]) = (a[i][1], a[i][0])
	if a[i][1] - a[i][0] > n / 2:
		a[i][0] += n
		(a[i][0], a[i][1]) = (a[i][1], a[i][0])
if m == 1:
	if a[0][1] - a[0][i] == n / 2:
		print('Yes')
	else:
		print('No')
	exit(0)
a.sort()
for i in range(m):
	a.append([a[i][0] + n, a[i][1] + n])
b = []
for i in range(2 * m - 1):
	if a[i][1] - a[i][0] == n / 2:
		b.append((a[i][1] - a[i][0], min(a[i + 1][0] - a[i][0], n - a[i + 1][0] + a[i][0])))
	else:
		b.append((a[i][1] - a[i][0], a[i + 1][0] - a[i][0]))
z = [0] * 2 * m
l = r = 0
for i in range(1, m):
	if i <= r:
		z[i] = min(z[i - l], r - i + 1)
	while i + z[i] < len(b) and b[i + z[i]] == b[z[i]]:
		z[i] += 1
	if i + z[i] - 1 > r:
		l = i
		r = i + z[i] - 1
	if z[i] >= m:
		print('Yes')
		exit(0)
print('No')


import math

class CodeforcesTask1147BSolution:

	def __init__(self):
		self.result = ''
		self.n_m = []
		self.points = []

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

	def process_task(self):
		can = False
		segm = {}
		for point in self.points:
			segm['{0}_{1}'.format(*point)] = True
			segm['{1}_{0}'.format(*point)] = True
		for k in range(1, self.n_m[0]):
			if not self.n_m[0] % k:
				do = True
				for p in self.points:
					(a, b) = ((p[0] + k) % self.n_m[0], (p[1] + k) % self.n_m[0])
					if not a:
						a = self.n_m[0]
					if not b:
						b = self.n_m[0]
					if not '{0}_{1}'.format(a, b) in segm:
						do = False
						break
				if do:
					can = do
					break
		self.result = 'Yes' if can else 'No'

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


import collections
import math
from math import gcd

def main():
	from sys import stdin, stdout

	def read():
		return stdin.readline().rstrip('\n')

	def read_array(sep=None, maxsplit=-1):
		return read().split(sep, maxsplit)

	def read_int():
		return int(read())

	def read_int_array(sep=None, maxsplit=-1):
		return [int(a) for a in read_array(sep, maxsplit)]

	def write(*args, **kwargs):
		sep = kwargs.get('sep', ' ')
		end = kwargs.get('end', '\n')
		stdout.write(sep.join((str(a) for a in args)) + end)

	def write_array(array, **kwargs):
		sep = kwargs.get('sep', ' ')
		end = kwargs.get('end', '\n')
		stdout.write(sep.join((str(a) for a in array)) + end)

	def list_factors(x):
		floor = math.floor(math.sqrt(x))
		lower_side = []
		higher_side = []
		for i in range(1, floor + 1):
			if x % i == 0:
				lower_side.append(i)
				higher_side.append(x // i)
		if lower_side[-1] == higher_side[-1]:
			higher_side.pop()
		return lower_side + higher_side[::-1]
	(n, m) = read_int_array()
	if m == n * (n - 1) // 2:
		write('Yes')
		return
	lines = collections.defaultdict(set)
	for _ in range(m):
		(a, b) = read_int_array()
		if a > b:
			(a, b) = (b, a)
		d = min(b - a, (a - b + n) % n)
		lines[d].add((a - 1, b - 1))
	if all((len(d_set) == n for d_set in lines.values())):
		write('Yes')
		return
	for i in range(2, n):
		if n % i == 0:
			win = True
			for line_set in lines.values():
				for (a, b) in line_set:
					(a, b) = ((a + i) % n, (b + i) % n)
					if a > b:
						(a, b) = (b, a)
					if (a, b) not in line_set:
						win = False
						break
				if not win:
					break
			else:
				write('Yes')
				return
	write('No')
main()


def getPrimeDivisors(n):
	primes = [True] * (n + 1)
	primes[0] = False
	primes[1] = False
	for i in range(2, n + 1):
		if primes[i]:
			tmp = i * 2
			while tmp <= n:
				primes[tmp] = False
				tmp += i
	divs = []
	for (k, v) in enumerate(primes):
		if v and n % k == 0:
			divs.append(k)
	return divs

def valid(div, n, s):
	inc = n // div
	for (a, b) in s:
		(a2, b2) = (a + inc, b + inc)
		if a2 > n:
			a2 -= n
		if b2 > n:
			b2 -= n
		if (a2, b2) in s or (b2, a2) in s:
			continue
		return False
	return True

def sol(n, s):
	divs = getPrimeDivisors(n)
	for div in divs:
		if valid(div, n, s):
			return 'Yes'
	return 'No'
[n, m] = [int(x) for x in input().split()]
s = set()
for _ in range(m):
	s.add(tuple([int(x) for x in input().split()]))
print(sol(n, s))


def getn():
	return int(input())

def getns():
	return [int(x) for x in input().split()]
(n, e) = getns()
ed = {}
es = []
ans = set()

def check(ns):
	d = {}
	for i in range(len(ns) - 1):
		l = ns[i + 1] - ns[i]
		d.setdefault(l, []).append(ns[i])
	l = ns[0] + n - ns[-1]
	d.setdefault(l, []).append(ns[-1])
	if len(d) == 1:
		ans.add(list(d.keys())[0])
		return
	for k in d.keys():
		check(d[k])
for i in range(e):
	(x, y) = getns()
	(x, y) = (max(x, y), min(x, y))
	if y + n - x < x - y:
		s = x
		l = y + n - x
		ed.setdefault(l, []).append(s)
	elif y + n - x == x - y:
		s = y
		l = x - y
		ed.setdefault(l, []).append(s)
		s = x
		l = y + n - x
		ed.setdefault(l, []).append(s)
	else:
		s = y
		l = x - y
		ed.setdefault(l, []).append(s)
for k in ed.keys():
	ed[k].sort()
	check(ed[k])
import math
ans = list(ans)
g = ans[0]
for i in range(1, len(ans)):
	g = g * ans[i] // math.gcd(g, ans[i])
if g < n and n % g == 0:
	print('Yes')
else:
	print('No')


def main():
	from sys import stdin, stdout

	def read():
		return stdin.readline().rstrip('\n')

	def read_array(sep=None, maxsplit=-1):
		return read().split(sep, maxsplit)

	def read_int():
		return int(read())

	def read_int_array(sep=None, maxsplit=-1):
		return [int(a) for a in read_array(sep, maxsplit)]

	def write(*args, **kwargs):
		sep = kwargs.get('sep', ' ')
		end = kwargs.get('end', '\n')
		stdout.write(sep.join((str(a) for a in args)) + end)

	def write_array(array, **kwargs):
		sep = kwargs.get('sep', ' ')
		end = kwargs.get('end', '\n')
		stdout.write(sep.join((str(a) for a in array)) + end)

	def list_factors(x):
		floor = math.floor(math.sqrt(x))
		lower_side = []
		higher_side = []
		for i in range(1, floor + 1):
			if x % i == 0:
				lower_side.append(i)
				higher_side.append(x // i)
		if lower_side[-1] == higher_side[-1]:
			higher_side.pop()
		return lower_side + higher_side[::-1]
	(n, m) = read_int_array()
	lines = set()
	for _ in range(m):
		(a, b) = read_int_array()
		lines.add((min(a, b) - 1, max(a, b) - 1))
	for i in range(1, n):
		if n % i == 0:
			for (a, b) in lines:
				(a, b) = ((a + i) % n, (b + i) % n)
				if a > b:
					(a, b) = (b, a)
				if (a, b) not in lines:
					break
			else:
				write('Yes')
				return
	write('No')
main()


from math import gcd

def primes():
	yield 2
	yield 3
	yield 5
	yield 7
	bps = (p for p in primes())
	p = next(bps) and next(bps)
	q = p * p
	sieve = {}
	n = 9
	while True:
		if n not in sieve:
			if n < q:
				yield n
			else:
				p2 = p + p
				sieve[q + p2] = p2
				p = next(bps)
				q = p * p
		else:
			s = sieve.pop(n)
			nxt = n + s
			while nxt in sieve:
				nxt += s
			sieve[nxt] = s
		n += 2
import itertools

def get_prime_divisors(limit):
	return list(itertools.filterfalse(lambda p: limit % p, itertools.takewhile(lambda p: p <= limit, primes())))
(n, m) = map(int, input().split())
data = {}
for _ in range(m):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b) - 1, max(a, b) - 1)
	(x, y) = (b - a, n - b + a)
	if x <= y:
		if x in data:
			data[x].add(a)
		else:
			data[x] = set([a])
	if y <= x:
		if y in data:
			data[y].add(b)
		else:
			data[y] = set([b])
t = n
for s in data.values():
	t = gcd(t, len(s))
if t == 1:
	print('No')
else:
	tests = get_prime_divisors(t)
	for k in tests:
		d = n // k
		for s in data.values():
			if any(map(lambda v: (v + d) % n not in s, s)):
				break
		else:
			print('Yes')
			break
	else:
		print('No')


def read_line():
	return list(map(int, input().split()))
seg = set()
(n, m) = read_line()
for _ in range(m):
	(x, y) = read_line()
	seg.add((min(x - 1, y - 1), max(x - 1, y - 1)))
for i in range(1, n):
	if n % i == 0:
		possible = True
		for (x, y) in seg:
			a = (x + i) % n
			b = (y + i) % n
			if (min(a, b), max(a, b)) not in seg:
				possible = False
				break
		if possible:
			print('Yes')
			exit(0)
print('No')


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
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')

class SegmentTree:

	def __init__(self, data, default=-10 ** 6, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree1:

	def __init__(self, data, default=10 ** 6, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(50001)]
pp = []

def SieveOfEratosthenes(n=50000):
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for i in range(50001):
		if prime[i]:
			pp.append(i)
(n, m) = map(int, input().split())
a = []
for i in range(m):
	(x, y) = map(int, input().split())
	(x, y) = (x - 1, y - 1)
	a.append((min(x, y), max(x, y)))
div = [1]
for i in range(2, 1 + int(math.sqrt(n))):
	if n % i == 0:
		div.append(i)
		if i * i != n:
			div.append(n // i)
div.sort()
ch = 0
s = set(a)
for k in div:
	c = 1
	for i in range(m):
		x = (a[i][0] + k) % n
		y = (a[i][1] + k) % n
		if (min(x, y), max(x, y)) not in s:
			c = 0
			break
	if c:
		ch = 1
		break
if ch:
	print('Yes')
else:
	print('No')


(n, m) = map(int, input().split())
a = set()
for i in range(m):
	(c, d) = map(int, input().split())
	c %= n
	d %= n
	a.add((min(c, d), max(c, d)))

def comprobar(x):
	global a, n
	b = set()
	for (c, d) in a:
		c += x
		d += x
		c %= n
		d %= n
		if (min(c, d), max(c, d)) not in a:
			return False
	return True
for i in range(1, n):
	if n % i == 0:
		if comprobar(i):
			print('Yes')
			exit()
print('No')