#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m;
set<pair<int, int> > S;
bool check(int add) {
  for (auto it : S) {
    int i = (it.first + add) % n;
    int j = (it.second + add) % n;
    if (i > j) swap(i, j);
    if (S.find({i, j}) == S.end()) return false;
  }
  return true;
}
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (fopen("main.in", "r"))
    freopen("main.in", "r", stdin);
  else if (fopen("something"
                 ".inp",
                 "r"))
    freopen(
        "something"
        ".inp",
        "r", stdin),
        freopen(
            "something"
            ".out",
            "w", stdout);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    S.insert({a, b});
  }
  for (int i = 1; i < n; i++)
    if (n % i == 0)
      if (check(i)) {
        cout << "YES\n";
        exit(0);
      }
  cout << "NO\n";
  return 0;
}
