#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> segs;
vector<pair<int, int>> temp;
int n, k;
bool solve(int x) {
  temp = segs;
  for (int i = 0; i < k; i++) {
    temp[i].first += x;
    temp[i].second += x;
    if (temp[i].first > n) temp[i].first -= n;
    if (temp[i].second > n) temp[i].second -= n;
    if (temp[i].first > temp[i].second) swap(temp[i].first, temp[i].second);
  }
  sort(temp.begin(), temp.end());
  return (temp == segs);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    int l, r;
    cin >> l >> r;
    if (l > r) swap(l, r);
    segs.push_back({l, r});
  }
  if (k == 1) {
    cout << "YES";
    return 0;
  }
  sort(segs.begin(), segs.end());
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      if (solve(n / i) || solve(i)) {
        cout << "YES";
        return 0;
      }
    }
  }
  cout << "NO";
  return 0;
}
