#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  long long ch[3];
  cin >> n >> k;
  for (long long i = 0; i < 3; i++) {
    ch[i] = -1;
  }
  for (long long i = 0; i < k; i++) {
    long long x, y;
    cin >> x >> y;
    x--;
    if (ch[x] == -1) {
      ch[x] = y;
    } else {
      if (ch[x] != y) {
        cout << -1;
        return 0;
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    if (i == 0) {
      if (ch[i] == 0) {
        if (n == 1) {
          cout << 0;
          return 0;
        }
        cout << -1;
        return 0;
      } else {
        cout << max(ch[i], long long(1));
      }
    } else {
      cout << max(ch[i], long long(0));
    }
  }
  return 0;
}
