#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  char a[n];
  for (int i = 0; i < (int)(n); i++) a[i] = 'x';
  bool d = true;
  for (int i = 0; i < (int)(m); i++) {
    long long s;
    char c;
    cin >> s >> c;
    if (a[s - 1] == 'x') {
      a[s - 1] = c;
    } else {
      if (a[s - 1] != c) {
        d = false;
        break;
      } else {
      }
    }
  }
  if (a[0] == '0') d = false;
  if (d == true) {
    for (long long i = 0; i < n; i++) {
      if (a[i] == 'x') {
        if (i == 0)
          cout << 1;
        else
          cout << 0;
      } else
        cout << a[i];
    }
  } else
    cout << -1;
}
