#include <bits/stdc++.h>
using namespace std;
int main() {
  int i = 0;
  int a[100] = {0};
  int c = 0;
  int e = 0;
  int val = 0;
  int b = 0;
  int n = 0;
  int m = 0;
  unordered_map<int, int> d;
  cin >> n;
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> c;
    cin >> b;
    if (d[c]) {
      cout << "-1";
      return 1;
    } else {
      d[c] = b;
    }
  }
}
