#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> data(m);
  for (int i = 0; i < m; ++i) {
    cin >> data[i].first >> data[i].second;
  }
  int cnt = 0, ans = 0;
  for (int i = 1; i <= 200; ++i) {
    bool fl = 0;
    for (int j = 0; j < m; ++j) {
      int floor = data[j].first / i + bool(data[j].first % i);
      if (floor != data[j].second) {
        fl = 1;
        break;
      }
    }
    if (!fl) {
      if (ans != n / i + (bool)(n % i)) {
        ++cnt;
        ans = n / i + (bool)(n % i);
      }
    }
  }
  if (cnt == 1) {
    cout << ans;
  } else {
    cout << -1;
  }
}
