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