#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  string ans(n, '?');
  while (m--) {
    int s;
    char c;
    cin >> s >> c;
    if ((ans[s - 1] == '?') || (ans[s - 1] == c)) {
      ans[s - 1] = c;
    } else {
      cout << -1 << '\n';
      return 0;
    }
  }
  if (ans[0] == '0') {
    cout << -1 << '\n';
    return 0;
  } else if (ans[0] == '?')
    ans[0] = '1';
  for (int i = 1; i < n; ++i) {
    if (ans[i] == '?') {
      ans[i] = '0';
    }
  }
  cout << ans << '\n';
  return 0;
}
