#include <bits/stdc++.h>
using namespace std;
vector<int> ff(101, -1);
int ceil(int a, int b) { return a / b + (a % b != 0 ? 1 : 0); }
bool check(int c) {
  for (int i = 1; i <= 100; ++i) {
    int curr = ceil(i, c);
    if (ff[i] != -1 && curr != ff[i]) return false;
  }
  return true;
}
void sol() {
  int n, m;
  ff[1] = 1;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int k, f;
    scanf("%d%d", &k, &f);
    ff[k] = f;
  }
  int ans = -1;
  for (int c = 1; c <= 100; ++c) {
    if (!check(c)) continue;
    if (ans != -1 && ans != ceil(n, c)) {
      ans = -1;
      break;
    } else {
      ans = ceil(n, c);
    }
  }
  printf("%d", ans);
}
int main() { sol(); }
