#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  ;
  long long N, M;
  cin >> N >> M;
  string s, ans;
  ans = " ";
  if (N == 1) s = "1";
  if (N == 2) s = "10";
  if (N == 3) s = "100";
  for (long long i = 0; i < (long long)(M); i++) {
    long long S;
    char c;
    cin >> S >> c;
    if (S == N && c == 0)
      ans = "-1";
    else if (s.at(S - 1) != c) {
      ans = "-1";
    } else if (c == '0')
      s.at(S - 1) = 'a';
    else
      s.at(S - 1) = c;
  }
  if (ans == "-1")
    cout << ans;
  else {
    for (long long i = 0; i < (long long)(N); i++) {
      if (s.at(i) == 'a') s.at(i) = '0';
    }
    cout << s;
  }
}
