#include <bits/stdc++.h>
using namespace std;
int k[110], f[110];
vector<int> vudka;
map<int, int> mp;
int main() {
  int n, i, j, m, fl = 0, rafi, tamu;
  cin >> n >> m;
  for (int i = 0; i < m; i++) scanf("%d%d", &k[i], &f[i]);
  if (m == 0) {
    if (n == 1)
      cout << 1 << "\n";
    else
      cout << -1 << "\n";
    return 0;
  }
  for (j = 1; j < 110; j++) {
    rafi = n / j;
    if (n % j != 0) rafi++;
    int mita = 0;
    for (int i = 0; i < m; i++) {
      tamu = k[i] / j;
      if (k[i] % j != 0) tamu++;
      if (f[i] != tamu) {
        mita = 1;
        break;
      }
    }
    if (mita == 0) {
      if (mp[rafi] == 0) {
        vudka.push_back(rafi);
        mp[rafi] = 1;
      }
    }
  }
  if (vudka.size() == 1)
    cout << vudka[0] << "\n";
  else
    cout << -1 << "\n";
}
