#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const long double pai = acos(-1);
int n, m;
int x[200009], y[200009];
set<pair<int, int> > s;
pair<int, int> edit(int x, int y) {
  if (x > y) swap(x, y);
  return {x, y};
}
void fill() {
  for (int i = 0; i < m; i++) s.insert(edit(x[i], y[i]));
}
pair<int, int> find(int id, int l) {
  int X = (x[id] + l) % n;
  int Y = (y[id] + l) % n;
  return {X, Y};
}
int check(int l) {
  fill();
  for (int i = 0; i < m; i++) {
    pair<int, int> x = find(i, l);
    x = edit(x.first, x.second);
    if (s.find(x) == s.end()) return 0;
    s.erase(x);
  }
  return 1;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x[i] >> y[i];
    x[i]--, y[i]--;
    if (x[i] > y[i]) swap(x[i], y[i]);
  }
  vector<int> d;
  for (int i = 1; i * i <= n; i++) {
    if (n % i) continue;
    d.push_back(i);
    if (i * i == n || n / i == n) continue;
    d.push_back(n / i);
  }
  for (auto u : d)
    if (check(u)) cout << "YES" << endl, exit(0);
  cout << "NO" << endl;
}
