#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, k, OK, a[107], f[107];
  set<int> ans;
  cin >> n >> m;
  for (i = 1; i <= m; i++) cin >> a[i] >> f[i];
  for (k = 1; k <= 100; k++) {
    OK = 1;
    for (i = 1; i <= m; i++)
      if ((a[i] + k - 1) / k != f[i]) {
        OK = 0;
        break;
      }
    if (OK) ans.insert((n + k - 1) / k);
  }
  if (ans.size() != 1)
    cout << -1;
  else
    cout << *ans.begin();
}
