#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, char>> sc(m);
  for (int i = 0; i < m; i++) {
    int s;
    char c;
    cin >> s >> c;
    sc[i] = make_pair(s, c);
  }
  sort(sc.begin(), sc.end());
  string ans = "";
  for (int i = 0; i < n; i++) ans += "r";
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (j == sc[i].first - 1 && ans[j] == 'r') {
        ans[j] = sc[i].second;
        break;
      } else if ((j == sc[i].first - 1) && (ans[j] != sc[i].second)) {
        cout << "-1" << endl;
        return 0;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (i > 0 && ans[i] == 'r') ans[i] = '0';
    if (i == 0 && ans[i] == 'r') ans[i] = '1';
  }
  if (ans[0] == '0') {
    cout << "-1" << endl;
    return 0;
  }
  cout << ans << endl;
}
