#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, i, j, k[101], f[101], ans = -1, kk;
  cin >> n >> m;
  vector<long long int> v[101];
  set<long long int> ans2;
  for (i = 0; i < m; i++) {
    cin >> k[i] >> f[i];
    v[f[i]].push_back(k[i]);
  }
  for (i = 1; i < 101; i++) {
    for (j = 1; j < 101; j++) {
      int ok = 5;
      if (v[j].size() != 0) {
        ok = 1;
        for (kk = 0; kk < v[j].size(); kk++) {
          if (v[j][kk] > i * (j - 1) && v[j][kk] <= i * j)
            ;
          else {
            ok = 0;
            break;
          }
        }
      }
      if (ok == 0) break;
    }
    if (j == 101) {
      ans2.insert((n + i - 1) / i);
    }
  }
  if (ans2.size() == 0 || ans2.size() > 1)
    cout << -1;
  else
    cout << *ans2.begin();
}
