#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)1e3 + 5;
const int MOD = (int)1e9 + 7;
using ll = long long int;
int n, m;
set<pair<int, int> > s;
int nxt(int x) {
  if (x <= n)
    return x;
  else
    return x - n;
}
bool rotate(int i) {
  for (pair<int, int> x : s) {
    int p1 = nxt(x.first + i), p2 = nxt(x.second + i);
    if (p1 > p2) swap(p1, p2);
    if (!s.count(make_pair(p1, p2))) return false;
  }
  return true;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a > b) swap(a, b);
    s.insert({a, b});
  }
  for (int i = 2; i <= n; ++i) {
    if (n % i == 0 && rotate(n / i)) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}
