#include <bits/stdc++.h>   using namespace std;   signed main() {     long long n, k;     scanf( %lld%lld , &n, &k);     long long coin = 0, sum = 0;     for (long long i = 1; i <= k; i++) {       long long a, b;       scanf( %lld%lld , &a, &b);       sum = (sum + a * b) % n;       coin += b;     }     if (coin > n) {       printf( -1 );       return 0;     }     if (coin < n) {       printf( 1 );       return 0;     }     if (sum == n * (n + 1) / 2 % n) {       printf( 1 );       return 0;     }     printf( -1 );     return 0;   }   