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