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