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