#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N, M;
  cin >> N >> M;
  string ans;
  for (long long i = 0; i < (long long)(N); i++) ans += 'a';
  for (long long i = 0; i < (long long)(M); i++) {
    long long s;
    cin >> s;
    char c;
    cin >> c;
    if (ans[s - 1] == 'a' || ans[s - 1] == c) {
      ans[s - 1] = c;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  for (long long i = 0; i < (long long)(N); i++)
    if (ans[i] == 'a') {
      if (i == 0)
        ans[i] = '1';
      else
        ans[i] = '0';
    }
  if (ans[0] == '0') {
    cout << -1 << endl;
    return 0;
  } else {
    cout << ans << endl;
    return 0;
  }
}
