#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j;
  cin >> n >> m;
  vector<int> A(n, 16);
  vector<int> S(m);
  vector<int> C(m);
  for (i = 0; i < m; i++) cin >> S[i] >> C[i];
  int ch = 0;
  for (i = 0; i < m; i++) {
    if (S[i] == 1 && C[i] == 0)
      ch = 1;
    else if (A[S[i] - 1] != 16) {
      if (A[S[i] - 1] != C[i])
        ch = 1;
      else
        ch = 0;
    } else
      A[S[i] - 1] = C[i];
  }
  for (i = 0; i < n; i++) {
    if (i == 0 && A[i] == 16)
      A[i] = 1;
    else if (A[i] == 16)
      A[i] = 0;
  }
  if (ch == 1)
    cout << -1 << endl;
  else {
    for (i = 0; i < n; i++) {
      cout << A[i];
    }
    cout << endl;
  }
}
