#include <bits/stdc++.h>
using namespace std;
map<int, char> mm;
void Solve() {
  int n, m;
  cin >> n >> m;
  string res = "";
  for (int i = 0; i < n; i++) res += '0';
  while (m--) {
    int p;
    char d;
    cin >> p >> d;
    if (p > n || (p == 1 && d == '0' && n > 1)) {
      cout << -1 << '\n';
      return;
    }
    if (!mm.count(p))
      res[p - 1] = d;
    else {
      if (mm[p] != d) {
        cout << -1 << '\n';
        return;
      }
    }
  }
  int i = 0;
  while (res[i] == '0') {
    res[i] = '1';
    i++;
  }
  cout << res << '\n';
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q = 1;
  while (q--) {
    Solve();
  }
}
