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