#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  string s(n, '?');
  int idx;
  char c;
  for (int i = 0; i < m; i++) {
    cin >> idx >> c;
    idx--;
    if (s[idx] == '?' || s[idx] == c) {
      s[idx] = c;
    } else {
      cout << -1 << endl;
      ;
      return 0;
    }
  }
  if (n == 1) {
    if (s[0] == '?') {
      s[0] = 0;
    }
  } else {
    if (s[0] == '0') {
      cout << -1 << endl;
      return 0;
    } else if (s[0] == '?') {
      s[0] = 1;
    }
  }
  for (int i = 1; i < n; i++) {
    if (s[i] == '?') {
      s[i] = '0';
    }
  }
  cout << s << endl;
  return 0;
}
