#include <bits/stdc++.h>
using namespace std;
int answ(int which, int flats) {
  if (which % flats == 0)
    return which / flats;
  else
    return which / flats + 1;
}
bool agile(int k, int f, int flats) {
  if (answ(k, flats) == f)
    return true;
  else
    return false;
}
int main() {
  int N, M;
  cin >> N;
  cin >> M;
  int k[105], f[105];
  for (int i = 1; i <= M; i++) {
    cin >> k[i];
    cin >> f[i];
  }
  int res = 0, resi = 1, curans = 999, flag = 0;
  for (int i = 1; i <= 100; i++) {
    bool allmempossible = true;
    for (int j = 1; j <= M; j++) {
      if (agile(k[j], f[j], i) == false) {
        allmempossible = false;
      }
    }
    if (allmempossible == true) {
      res++;
      resi = i;
      if (curans != answ(N, i) && curans != 999) {
        flag = 1;
      }
      curans = answ(N, i);
    }
  }
  if (flag == 0) {
    cout << answ(N, resi) << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
