#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007LL;
int main() {
  int N, M;
  string num = "";
  cin >> N >> M;
  for (int i = 0; i < N; ++i) num += "*";
  for (int i = 0; i < M; ++i) {
    int s;
    char c;
    cin >> s >> c;
    if (num[s - 1] != '*' && num[s - 1] != c) {
      cout << -1 << "\n";
      return 0;
    } else {
      num[s - 1] = c;
    }
  }
  if (num[0] == '0' && N != 1) {
    cout << -1 << "\n";
    return 0;
  } else if (num[0] == '*') {
    num[0] = '1';
  }
  for (int i = 0; i < N; ++i) {
    if (num[i] == '*') {
      num[i] = '0';
    }
  }
  cout << num << "\n";
  return 0;
}
