#include <bits/stdc++.h>
using namespace std;
vector<long long> find(long long n) {
  vector<long long> ans;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ans.push_back(i);
      if (i == 1) continue;
      if (n / i != i) ans.push_back(n / i);
    }
  }
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  pair<long long, long long> arr[m];
  for (long long i = 0; i < m; i++) {
    cin >> arr[i].first >> arr[i].second;
    if (arr[i].first > arr[i].second) swap(arr[i].first, arr[i].second);
  }
  map<pair<long long, long long>, long long> mp;
  for (long long i = 0; i < m; i++) {
    mp[arr[i]] = 1;
  }
  vector<long long> a = find(n);
  for (long long i = 0; i < a.size(); i++) {
    long long cnt = 0;
    for (long long j = 0; j < m; j++) {
      long long x = arr[j].first + a[i];
      x %= n;
      if (x == 0) x += n;
      long long y = arr[j].second + a[i];
      y %= n;
      if (y == 0) y += n;
      if (x > y) swap(x, y);
      if (mp[{x, y}] == 0) break;
      cnt++;
    }
    if (cnt == m) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
