#include <bits/stdc++.h>
using namespace std;
struct point {
  double x, y;
  double dist(point t) {
    return sqrt((x - t.x) * (x - t.x) + (y - t.y) * (y - t.y));
  }
};
int main() {
  int n, m, ma = 9999999, mi = -1;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int k, f;
    cin >> k >> f;
    if (k % f != 0)
      mi = max(mi, k / f + 1);
    else
      mi = max(mi, k / f);
    if (f > 1) ma = min(ma, (k - 1) / (f - 1));
  }
  int f1, f2;
  if (mi * ma != 0) {
    if (n % mi != 0)
      f1 = n / mi + 1;
    else
      f1 = n / mi;
    if (n % ma != 0)
      f2 = n / ma + 1;
    else
      f2 = n / ma;
  }
  if (n != 1) {
    if (f1 == f2)
      cout << f1;
    else
      cout << -1;
  } else {
    cout << 1;
  }
}
