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