#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e9 + 7;
const long long MAXL = 1e18;
const int N = 2 * 1e5 + 10;
const double eps = 1e-13;
ifstream in("inverse.in");
ofstream out("inverse.out");
struct Node {
  int x, y, cnt;
  Node *l, *r;
  Node() {
    l = nullptr;
    r = nullptr;
    y = 0;
    x = 0;
    cnt = 1;
  }
};
Node* recalc(Node* t) {
  t->cnt = 1;
  if (t->l != nullptr) t->cnt += t->l->cnt;
  if (t->r != nullptr) t->cnt += t->r->cnt;
  return t;
}
pair<Node*, Node*> split(Node* t, int x) {
  if (t == nullptr) return {t, t};
  if (t->x > x) {
    pair<Node*, Node*> pr = split(t->l, x);
    t->l = pr.second;
    t = recalc(t);
    return {pr.first, t};
  } else {
    pair<Node*, Node*> pr = split(t->r, x);
    t->r = pr.first;
    t = recalc(t);
    return {t, pr.second};
  }
}
Node* merge(Node* tl, Node* tr) {
  if (tl == nullptr || tr == nullptr) return tl == nullptr ? tr : tl;
  if (tl->y > tr->y) {
    tl->r = merge(tl->r, tr);
    tl = recalc(tl);
    return tl;
  } else {
    tr->l = merge(tl, tr->l);
    tr = recalc(tr);
    return tr;
  }
}
Node* insert(Node* tree, Node* t) {
  pair<Node*, Node*> p = split(tree, t->x);
  return merge(merge(p.first, t), p.second);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<bool> ans(111, true);
  for (int i = 0; i < m; ++i) {
    int k, l;
    cin >> k >> l;
    for (int j = 1; j <= 110; ++j) {
      if (ans[j]) {
        if (l * j < k || (l - 1) * j >= k) ans[j] = false;
      }
    }
  }
  int out = 0;
  for (int i = 1; i <= 110; ++i) {
    if (ans[i]) {
      if (!out || (n / i + (int)(n % i != 0) == out))
        out = n / i + (int)(n % i != 0);
      else {
        cout << "-1\n";
        return 0;
      }
    }
  }
  cout << out << '\n';
  return 0;
}
