#include <bits/stdc++.h>
using namespace std;
pair<int, int> a[105];
int n, m;
int main() {
  cout.precision(10);
  cout << fixed;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) cin >> a[i].first >> a[i].second;
  int ans = -1;
  for (int num = 1; num <= 100; ++num) {
    bool bad = 0;
    for (int i = 0; i < m; ++i) {
      int tmp = ((a[i].first + num - 1) / num);
      if (tmp != a[i].second) {
        bad = 1;
        break;
      }
    }
    if (!bad) {
      if (ans == -1)
        ans = (n + num - 1) / num;
      else if (ans != (n + num - 1) / num) {
        ans = -1;
        break;
      }
    }
  }
  cout << ans;
}
