#include <bits/stdc++.h>
using namespace std;
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int s[M], c[M];
  for (int i = 0; i < M; i++) {
    cin >> s[i] >> c[i];
  }
  int n[3] = {-1, -1, -1};
  bool flag = true;
  for (int i = 0; i < M; i++) {
    n[s[i] - 1] = c[i];
    for (int j = 0; j < M; j++) {
      if (s[i] == s[j] && c[i] != c[j]) flag = false;
    }
    if (s[i] == 1 && c[i] == 0 && N != 1) flag = false;
  }
  if (flag) {
    int ans = 0;
    for (int i = 0; i < N; i++) {
      if (n[i] == -1) {
        if (i == 0)
          n[i] = 1;
        else
          n[i] = 0;
      }
      cout << n[i];
    }
    cout << endl;
  } else
    cout << -1 << endl;
}
