#include <bits/stdc++.h>
using namespace std;
int n, m, sz, d[1001], a[200002], b[200002];
set<pair<int, int> > s;
void div() {
  sz = 0;
  for (int i = 1; i <= trunc(sqrt(n)); i++)
    if (n % i == 0) {
      d[++sz] = i;
      if (i * i != n && i != 1) d[++sz] = n / i;
    }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> a[i] >> b[i];
    s.insert(pair<int, int>(a[i], b[i]));
    s.insert(pair<int, int>(b[i], a[i]));
  }
  div();
  bool check;
  for (int i = 1; i <= sz; i++) {
    check = 1;
    for (int j = 1; j <= m; j++) {
      int x = a[j] + d[i];
      int y = b[j] + d[i];
      if (x > n) x -= n;
      if (y > n) y -= n;
      if (!s.count(pair<int, int>(x, y))) check = 0;
    }
    if (check) return cout << "YES", 0;
  }
  cout << "NO";
  return 0;
}
