#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long T = 1;
  while (T--) {
    long long n, m, i;
    cin >> n >> m;
    string s = "";
    long long tem = n;
    while (tem--) s.push_back('#');
    char c;
    for (i = 0; i < m; i++) {
      cin >> tem >> c;
      tem--;
      if (s[tem] == '#')
        s[tem] = c;
      else if (s[tem] != c) {
        cout << -1;
        return 0;
      }
    }
    if (s[0] == '0') {
      cout << -1;
      return 0;
    }
    if (s[0] == '#') s[0] = '1';
    for (i = 1; i < n; i++) {
      if (s[i] == '#') s[i] = '0';
    }
    cout << s;
  }
  return 0;
}
