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