#include <bits/stdc++.h>
using namespace std;
int n, m;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  string s(n, '#');
  for (int i = 0; i < m; ++i) {
    int pos;
    char val;
    cin >> pos >> val;
    pos--;
    if (s[pos] != '#') {
      if (val == s[pos])
        continue;
      else {
        cout << -1;
        return 0;
      }
    }
    s[pos] = val;
  }
  if (s[0] == '#' || s[0] == '0') {
    cout << -1;
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    if (s[i] == '#') s[i] = '0';
  }
  cout << s;
}
