#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int s[10];
  char c[10];
  char a[3];
  bool res = true;
  for (int i = 0; i < n; i++) {
    a[i] = '0';
  }
  a[0] = '1';
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
    a[s[i] - 1] = c[i];
    if (s[i] == 1 && c[i] == '0') {
      res = false;
      break;
    }
    for (int j = 0; j < i; j++) {
      if (s[i] == s[j] && c[i] != c[j]) {
        res = false;
      }
    }
  }
  if (res) {
    for (int i = 0; i < n; i++) {
      cout << a[i];
    }
  } else {
    cout << "-1";
  }
  cout << '\n';
}
