#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<char> s(n, 'a');
  for (int i = 0; i < m; i++) {
    int p;
    cin >> p;
    p--;
    char c;
    cin >> c;
    if (s[p] == 'a') {
      s[p] = c;
    } else {
      if (s[p] != c) {
        cout << -1 << endl;
        return 0;
      }
    }
    if (p == 0 && c == '0') {
      cout << -1 << endl;
      return 0;
    }
  }
  if (s[0] == 'a') s[0] = '1';
  for (int i = 0; i < n; i++) {
    if (s[i] == 'a') s[i] = '0';
    cout << s[i];
  }
  cout << endl;
  return 0;
}
