#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct kmp {
  int P;
  vector<T> word;
  vector<int> fail;
  int adv(int len, const T& nxt) const {
    while (len > 0 && word[len] != nxt) len = fail[len];
    return len + int(word[len] == nxt);
  }
  kmp(const vector<T>& word) : P(word.size()), word(word) {
    fail.resize(P + 1);
    for (int i = 2; i <= P; i++) fail[i] = adv(fail[i - 1], word[i - 1]);
  }
  vector<bool> find(const vector<T>& text) const {
    vector<bool> match(text.size());
    for (int i = 0, len = 0; i < text.size(); i++) {
      len = adv(len, text[i]);
      if (len == P) {
        match[i - len + 1] = true;
        len = fail[len];
      }
    }
    return match;
  }
};
const int MAXN = 101010;
int N, M;
vector<int> delta[MAXN];
void debug_vector(const vector<int>& v) {
  for (int i = 0; i < v.size(); ++i) {
    printf("%d ", v[i]);
  }
  printf("\n");
}
int main() {
  scanf("%d %d", &N, &M);
  for (int i = 0; i < M; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--;
    b--;
    delta[a].push_back((b - a + N) % N);
    delta[b].push_back((a - b + N) % N);
  }
  vector<int> str;
  for (int i = 0; i < N; ++i) {
    sort(delta[i].begin(), delta[i].end());
    str.push_back(-1);
    for (int j = 0; j < delta[i].size(); ++j) {
      str.push_back(delta[i][j]);
    }
  }
  vector<int> str2;
  for (int rep = 0; rep < 2; ++rep) {
    for (int i = 0; i < str.size(); ++i) {
      str2.push_back(str[i]);
    }
  }
  kmp<int> matcher(str);
  vector<bool> res = matcher.find(str2);
  for (int i = 1; i < str.size(); ++i) {
    if (res[i]) {
      printf("YES\n");
      return 0;
    }
  }
  printf("NO\n");
  return 0;
}
