#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > inp;
  int x, y;
  int ans = -1;
  set<int> pos;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    inp.push_back({x, y});
  }
  for (int i = 1; i <= 100; i++) {
    int j, flr = i;
    for (j = 0; j < m; j++) {
      float t = (float)(inp[j].first) / flr;
      if (ceil(t) != inp[j].second) break;
    }
    if (j == m) {
      float t = (float)n / flr;
      pos.insert(ceil(t));
    }
  }
  if (pos.size() == 1)
    cout << *pos.begin() << endl;
  else
    cout << -1;
  return 0;
}
