#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M);
  vector<char> c(M);
  for (int i = 0; i < M; i++) cin >> s[i] >> c[i];
  vector<char> ans(N, 'x');
  for (int i = 0; i < M; i++) {
    if (s[i] - 1 > N) {
      cout << -1 << endl;
      return 0;
    }
    if (ans[s[i] - 1] == 'x') {
      ans[s[i] - 1] = c[i];
    } else if (ans[s[i] - 1] != c[i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (ans[0] == '0' && N > 1) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < N; i++) {
    if (ans[i] == 'x') {
      if (i == 0)
        ans[i] = '1';
      else
        ans[i] = '0';
    }
  }
  for (int i = 0; i < N; i++) cout << ans[i];
  cout << endl;
  return 0;
}
