#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> bc;
  int s[m];
  int c[m];
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
    for (int j = 0; j < i; j++) {
      if (s[i] == s[j] && c[i] != c[j]) {
        goto ERROR;
      }
    }
  }
  bc[0] = 1;
  for (int i = 1; i < n; i++) {
    bc[i] = 0;
  }
  for (int i = 0; i < m; i++) {
    bc[s[i] - 1] = c[i];
  }
  if (bc[0] == 0 && n != 1) {
    goto ERROR;
  }
  for (int i = 0; i < n; i++) {
    cout << bc[i];
  }
  cout << endl;
  return 0;
ERROR:
  cout << "-1" << endl;
}
