#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const long long inf = 1e18;
int k[105], f[105], n, m;
bool check(int kk) {
  for (int i = 0; i < m; i++) {
    if (f[i] * kk >= k[i] && (f[i] - 1) * (kk) < k[i]) continue;
    return 0;
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  if (n == 1 && m == 0) {
    cout << 1 << endl;
    return 0;
  }
  for (int i = 0; i < m; i++) {
    cin >> k[i] >> f[i];
  }
  int ans = 0;
  for (int i = 1; i < 1000; i++) {
    if (check(i)) {
      if (!ans)
        ans = (n + i - 1) / i;
      else if (ans != (n + i - 1) / i) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;
}
