#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[i] = 'x';
  int s;
  char c;
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    if (num[s - 1] != 'x' && num[s - 1] == c) {
      cout << -1 << endl;
      return 0;
    }
    if (n != 0 && s == 1 && c == 0) {
      cout << -1 << endl;
      return 0;
    }
    num[s - 1] = c;
  }
  for (int i = 0; i < n; i++) {
    if (num[i] == 'x') {
      if (i == 0)
        num[i] = '1';
      else
        num[i] = '0';
    }
  }
  cout << num << endl;
}
