#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n, m;
  cin >> n >> m;
  string ans{"aaa"};
  bool err = false;
  for (int i = 0; i < (int)(m); i++) {
    int s;
    char c;
    cin >> s >> c;
    s--;
    if (ans[s] == 'a' || ans[s] == c) {
      ans[s] = c;
    } else {
      err = true;
    }
  }
  if (ans[0] == '0') err = true;
  for (int i = 0; i < (int)(n); i++) {
    if (ans[i] == 'a') {
      if (i == 0)
        ans[i] = '1';
      else
        ans[i] = '0';
    }
  }
  if (!err)
    cout << ans << endl;
  else
    cout << -1 << endl;
}
