#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using mii = map<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int N = 1e2 + 5;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<pii> kf(m);
  for (int i = (0); i < (m); i++) cin >> kf[i].first >> kf[i].second;
  vi possible;
  for (int lvl = (1); lvl < (101); lvl++) {
    bool ok = true;
    for (auto [flat, level] : kf) {
      if (lvl * level >= flat && (level - 1) * lvl < flat) continue;
      ok = false;
      break;
    }
    if (ok) possible.push_back(lvl);
  }
  bool multiple = false;
  int ans = -1;
  for (auto lvl : possible) {
    if (false) cerr << lvl << endl;
    if (ans == -1) {
      ans = (n + lvl - 1) / lvl;
    } else {
      int tp = (n + lvl - 1) / lvl;
      if (tp != ans) {
        multiple = true;
        break;
      }
    }
  }
  if (ans == -1 || multiple)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
