#include <bits/stdc++.h>   using namespace std;   long long power(long long x, long long y, long long md = 1000000007) {     long long res = 1;     x %= md;     while (y > 0) {       if (y & 1) res = (res * x) % md;       x = (x * x) % md;       y = y >> 1;     }     return res % md;   }   signed main() {     long long n, m;     cin >> n >> m;     long long root = sqrt(n) + 1;     std::vector<long long> factors;     std::vector<pair<int, int> > v(m);     for (int i = 1; i < root; i++) {       if (n % i) continue;       long long temp = n / i;       factors.push_back(i);       if (i != temp && temp != n) factors.push_back(temp);     }     std::vector<long long> check(m, 0);     std::map<pair<long long, long long>, long long> map;     for (int i = 0; i < m; i++) {       long long a, b;       cin >> a >> b;       a--;       b--;       if (b < a) swap(a, b);       v[i] = make_pair(a, b);       map[v[i]] = i;     }     for (int i = 0; i < factors.size(); i++) {       for (int j = 0; j < m; j++) check[i] = 0;       long long x = factors[i];       long long first = 1;       for (int j = 0; j < m; j++) {         long long a = min((v[j].first + x) % n, (v[j].second + x) % n);         long long b = max((v[j].first + x) % n, (v[j].second + x) % n);         std::map<pair<long long, long long>, long long>::iterator it =             map.find(make_pair(a, b));         if (it == map.end()) {           first = 0;           break;         }       }       if (first) {         cout <<  Yes ;         return 0;       }     }     cout <<  No ;   }   