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