using
System;
using
System.Collections.Generic;
class
GFG {
static
List<
int
> calculateDivisors(
int
N)
{
List<
int
> div =
new
List<
int
>();
for
(
int
i = 1; i * i <= N; i++) {
if
(N % i == 0) {
div.Add(i);
if
(N / i != i && i != 1) {
div.Add(N / i);
}
}
}
return
div;
}
static
int
checkRotationallySymmetric(List<Tuple<
int
,
int
> > A,
int
N,
int
M)
{
HashSet<Tuple<
int
,
int
> > st
=
new
HashSet<Tuple<
int
,
int
> >();
for
(
int
i = 0; i < M; i++) {
A[i] =
new
Tuple<
int
,
int
>(A[i].Item1 - 1,
A[i].Item2 - 1);
if
(A[i].Item1 > A[i].Item2) {
A[i] =
new
Tuple<
int
,
int
>(A[i].Item2,
A[i].Item1);
}
st.Add(A[i]);
}
List<
int
> div = calculateDivisors(N);
foreach
(
var
x
in
div)
{
bool
exist =
true
;
for
(
int
i = 0; i < M; i++) {
int
dx = (A[i].Item1 + x) % N;
int
dy = (A[i].Item2 + x) % N;
if
(dx > dy) {
Tuple<
int
,
int
> temp
=
new
Tuple<
int
,
int
>(dy, dx);
dx = temp.Item1;
dy = temp.Item2;
}
if
(st.Contains(
new
Tuple<
int
,
int
>(dx, dy))) {
}
else
{
exist =
false
;
break
;
}
}
if
(exist) {
Console.WriteLine(
"YES"
);
return
0;
}
}
Console.WriteLine(
"NO"
);
return
0;
}
static
void
Main(
string
[] args)
{
int
N = 12, M = 6;
List<Tuple<
int
,
int
> > C
=
new
List<Tuple<
int
,
int
> >{
new
Tuple<
int
,
int
>(1, 3),
new
Tuple<
int
,
int
>(3, 7),
new
Tuple<
int
,
int
>(5, 7),
new
Tuple<
int
,
int
>(7, 11),
new
Tuple<
int
,
int
>(9, 11),
new
Tuple<
int
,
int
>(11, 3)
};
checkRotationallySymmetric(C, N, M);
}
}