#include <bits/stdc++.h>
using namespace std;
int a[105];
int b[105];
int n, m;
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a[i], &b[i]);
  }
  int flag = -1;
  int ans = -1;
  for (int i = 1; i <= 100; i++) {
    int ok = 1;
    for (int j = 0; j < m; j++) {
      if ((a[j] + (i)-1) / i != b[j]) {
        ok = 0;
        break;
      }
    }
    if (ok) {
      if (flag == -1 || ans == -1 || ans == (n + i - 1) / i) {
        flag = 1;
        ans = (n + i - 1) / i;
      } else {
        flag = 0;
        break;
      }
    }
  }
  if (flag)
    cout << ans << endl;
  else
    puts("-1");
}
