#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n, k[100], f[100], ot, i, j, d;
  cin >> n >> m;
  for (i = 0; i < m; i++) cin >> k[i] >> f[i];
  ot = -1;
  for (i = 1; i <= 100; i++) {
    bool ok = true;
    for (j = 0; j < m; j++) {
      d = ceil(k[j] / float(i));
      if (d != f[j]) {
        ok = false;
        break;
      }
    }
    if (!ok)
      ;
    else if (ot == -1)
      ot = ceil(float(n) / i);
    else if (ot != ceil(float(n) / i)) {
      cout << -1;
      return 0;
    };
  }
  cout << ot;
  return 0;
}
