#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, m;
  cin >> n;
  cin >> m;
  long long int A[n];
  long long int i, f;
  for (i = 0; i < n; i += 1) {
    A[i] = -1;
  }
  f = 1;
  for (i = 0; i < m; i += 1) {
    long long int si, dg;
    cin >> si;
    cin >> dg;
    if (n == 1) {
      if (A[si - 1] == -1 || A[si - 1] == dg)
        A[si - 1] = dg;
      else
        f = 0;
    } else {
      if (si == 1 && dg == 0) f = 0;
      if (A[si - 1] == -1 || A[si - 1] == dg)
        A[si - 1] = dg;
      else
        f = 0;
    }
  }
  if (f == 0)
    cout << "-1"
         << "\n";
  else {
    for (i = 0; i < n; i += 1) {
      if (A[i] == -1) {
        if (i == 0)
          A[i] = 1;
        else
          A[i] = 0;
      }
      cout << A[i];
    }
  }
  return 0;
}
