#include <bits/stdc++.h>
using namespace std;
const long long TAM = 1e5 + 10;
long long n, m;
vector<long long> arr[TAM];
bool solve(long long t) {
  long long j;
  if (t == n) return false;
  for (long long i = 0; i < n; i++) {
    j = (t + i) % n;
    if (arr[i].size() != arr[j].size()) return false;
    vector<long long> v;
    for (long long x : arr[i]) v.push_back((x + t) % n);
    sort(v.begin(), v.end());
    if (v != arr[j]) return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  bool ok = false;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    arr[a].push_back(b);
    arr[b].push_back(a);
  }
  for (long long i = 0; i < n; i++) sort(arr[i].begin(), arr[i].end());
  for (long long i = 1; i * i <= n and !ok; i++) {
    if (n % i != 0) continue;
    ok = ok or solve(i);
    if (i * i != n) ok = ok or solve(n / i);
  }
  if (ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
