#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s;
  vector<char> c(m);
  bool ok = true;
  for (int i = 0; i < (m); ++i) {
    int t;
    cin >> t >> c[i];
    for (int j = 0; j < (s.size()); ++j) {
      if (s[j] == t - 1 && c[j] != c[i]) {
        ok = false;
      }
    }
    if (t == 1 && c[i] == '0') {
      ok = false;
    }
    s.push_back(--t);
  }
  string ans(n, '0');
  ans[0] = '1';
  for (int i = 0; i < (m); ++i) {
    ans[s[i]] = c[i];
  }
  if (ok)
    cout << ans << endl;
  else
    cout << -1 << endl;
  return 0;
}
