#include <bits/stdc++.h>
using namespace std;
const long long int maxr = 1e5 + 5;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n, m;
  cin >> n >> m;
  string ans = "###";
  for (long long int i = 0; i < m; i++) {
    long long int s;
    char c;
    cin >> s >> c;
    if (ans[s - 1] == '#') {
      ans[s - 1] = c;
    } else {
      if (ans[s - 1] == c)
        continue;
      else {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  if (ans[0] == '0' || ans[0] == '#' && ans[1] == '0')
    cout << -1 << endl;
  else {
    if (ans[0] == '#') ans[0] = '1';
    if (ans[1] == '#') ans[1] = '0';
    if (ans[2] == '#') ans[2] = '0';
    cout << ans << endl;
  }
  return 0;
}
