#include <bits/stdc++.h>
using namespace std;
int main() {
  set<int> s;
  long long t, n, l = 0, r = 1e9, sum = 0, ans = 0, k;
  cin >> k >> n;
  pair<int, int> a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
  }
  for (int i = 1; i <= 100; i++) {
    bool f = 1;
    for (int j = 0; j < n; j++) {
      if ((a[j].first + i - 1) / i != a[j].second) {
        f = 0;
        break;
      }
    }
    if (f) {
      s.insert((k + i - 1) / i);
    }
  }
  if (s.size() != 1) {
    cout << -1;
  } else {
    cout << *s.begin();
  }
}
