#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(M);
  vector<char> c(M);
  for (int i = 0; i < M; ++i) cin >> s[i] >> c[i];
  vector<char> number(3);
  for (int i = 0; i < N; ++i) number[i] = 'A';
  for (int i = 0; i < M; ++i) {
    if (number[s[i] - 1] == 'A')
      number[s[i] - 1] = c[i];
    else if (number[s[i] - 1] != c[i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (number.size() != 1 && number[0] == '0') {
    cout << -1 << endl;
    return 0;
  };
  for (int i = 0; i < N; ++i) {
    if (number[i] == 'A') number[i] = '0';
  }
  if (number.size() != 1 && number[0] == '0') number[0] = '1';
  for (int i = 0; i < N; ++i) cout << number[i];
  cout << endl;
  return 0;
}
