#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int s[15], c[15], a[4] = {0}, b[4] = {0}, p[4] = {0};
  cin >> n >> m;
  int f1 = 0;
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
    if ((b[s[i]] != c[i] && p[s[i]]) | (s[i] == 1 && c[i] == 0)) {
      f1 = 1;
    }
    a[s[i]] = c[i];
    b[s[i]] = c[i];
    p[s[i]] = 1;
  }
  int f2 = 1;
  if (f1) {
    cout << -1;
  } else {
    if (a[1] == 0) a[1] = 1;
    for (int i = 1; i <= n; i++) cout << a[i];
  }
  return 0;
}
