#define _CRT_SECURE_NO_WARNINGS #define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING #include using namespace std; template <> struct hash> { size_t operator()(const pair &v) const { return *((long long *)&v); } }; int main() { unordered_set> S; int n, m; scanf("%d%d", &n, &m); for (int i = 0; i < m; i++) { int x, y; scanf("%d%d", &x, &y); x--, y--; if (x > y) swap(x, y); S.insert({x, y}); } vector v; for (long long i = 1; i * i <= n; i++) if (n % i == 0) { v.push_back(i); if (i != 1) v.push_back(n / i); } for (auto i : v) if (n % i == 0) if (all_of(S.begin(), S.end(), [&](const pair &p) { int x = (p.first + i) % n; int y = (p.second + i) % n; if (x > y) swap(x, y); return S.count({x, y}); })) { puts("Yes"); return 0; } puts("No"); return 0; }