#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, f = 1, i, j, indx, val;
  cin >> n >> m;
  int a[n + 1];
  for (i = 0; i <= n; i++) a[i] = -1;
  if (n == 1 && m == 0) {
    cout << 0 << endl;
    return 0;
  }
  for (i = 0; i < m; i++) {
    cin >> indx >> val;
    if (n >= 1 && indx == 1 && val == 0)
      f = 0;
    else if (a[indx] == -1 || a[indx] == val)
      a[indx] = val;
    else
      f = 0;
  }
  if (f == 0)
    cout << -1 << endl;
  else {
    for (i = 1; i <= n; i++) {
      if (a[i] == -1 && i == 1)
        a[i] = 1;
      else if (a[i] == -1)
        a[i] = 0;
      cout << a[i];
    }
    cout << endl;
  }
  return 0;
}
