#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
y:
  cin.tie(0);
  cout.tie(0);
  cin.sync_with_stdio(0);
  ;
  ll n = 0, k = 0;
  cin >> n >> k;
  ll a = 0, b = 0;
  ll sum = 0;
  ll pos = 0;
  for (int i = 0; i < k; ++i) {
    cin >> a >> b;
    sum += b;
    pos += a * b;
  }
  if (sum < n)
    cout << 1 << "\n";
  else {
    if (!(pos % n == (n * (n - 1)) / 2 % n))
      cout << -1 << "\n";
    else
      cout << 1 << "\n";
  }
  return 0;
}
