#include <bits/stdc++.h>
using namespace std;
int main() {
  int max = 100, min = -1;
  int n, m;
  cin >> n >> m;
  int a[m][2];
  for (int i = 0; i < m; i++) {
    cin >> a[i][0];
    cin >> a[i][1];
    int x = a[i][0];
    int f = a[i][1];
    int maxtemp = max;
    int mintemp = min;
    if (f == 1) {
      maxtemp = max;
      mintemp = (ceil)(x / (float)f);
    } else {
      maxtemp = (floor)(x - 1) / (float)(f - 1);
      mintemp = (ceil)(x / (float)f);
    }
    if (min < mintemp) {
      min = mintemp;
    }
    if (max > maxtemp) {
      max = maxtemp;
    }
  }
  cout << endl;
  if (m == 0) {
    if (n == 1)
      cout << "1" << endl;
    else {
      cout << "-1" << endl;
    }
  } else {
    int ans1 = ceil(n / (float)max);
    int ans2 = ceil(n / (float)min);
    if (ans1 == ans2) {
      cout << ans1 << endl;
    } else {
      cout << "-1" << endl;
    }
  }
  return 0;
}
