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