#include <bits/stdc++.h>
using namespace std;
double const EPS = 1e-9, PI = acos(-1);
const int N = 2e5 + 9, M = 2e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const long long inf = 1e18;
pair<int, int> pts[N];
int main() {
  cout << fixed << setprecision(9), ios::sync_with_stdio(false),
      cin.tie(nullptr), cout.tie(nullptr);
  int n, m, u, v;
  map<pair<int, int>, bool> mp;
  cin >> n >> m;
  vector<int> fact;
  for (int i = 2; (long long)i * (long long)i <= n; ++i) {
    if (n % i == 0) {
      fact.push_back(i);
      if (n / i != i) fact.push_back(n / i);
    }
  }
  fact.push_back(1);
  sort(fact.begin(), fact.end());
  for (int i = 0; i < m; ++i) {
    cin >> u >> v;
    if (u > v) swap(u, v);
    mp[{u, v}], pts[i] = {u, v};
  }
  for (auto it : fact) {
    int cnt = 0;
    for (int i = 0; i < m; ++i) {
      u = (pts[i].first + it), v = (pts[i].second + it);
      if (u > n) u %= n;
      if (v > n) v %= n;
      if (u > v) swap(u, v);
      if (mp.find({u, v}) != mp.end()) ++cnt;
    }
    if (cnt == m) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}
