#include <bits/stdc++.h>
using namespace std;
signed main(void) {
  long long n, m;
  cin >> n >> m;
  vector<char> ans(n, '0');
  for (long long i = 0; i < m; i++) {
    long long s;
    char c;
    cin >> s >> c;
    s--;
    if (ans[s] != '0' && ans[s] != c) {
      cout << -1 << endl;
      return 0;
    }
    ans[s] = c;
  }
  if (ans[0] == '0') {
    ans[1] = '1';
  }
  for (long long i = 0; i < n; i++) {
    cout << ans[i];
  }
  cout << endl;
  return 0;
}
