#include <bits/stdc++.h>
using namespace std;
const long long INF = LLONG_MAX;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  string s = "";
  for (int i = 0; i < n; i++) s += '.';
  bool ok = 1;
  int p;
  char x;
  for (int i = 0; i < m; i++) {
    cin >> p >> x;
    p--;
    if (!ok) continue;
    if (s[p] == '.')
      s[p] = x;
    else if (s[p] != x) {
      ok = 0;
    }
  }
  if (s[0] == '0' && n > 1) ok = 0;
  if (ok) {
    if (s[0] == '.') s[0] = '1';
    for (int i = 1; i < n; i++) {
      if (s[i] == '.') s[i] = '0';
    }
    cout << s << '\n';
  } else
    cout << -1 << '\n';
}
