#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<char> C(N, ' ');
  for (int i = 0; i < M; i++) {
    int s;
    char c;
    cin >> s >> c;
    s--;
    if ((C[s] == ' ') || (C[s] == c)) {
      C[s] = c;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  if ((C[0] == 0) && (N != 1)) {
    return 0;
  }
  vector<char> ans(N, ' ');
  for (int i = 0; i < N; i++) {
    if (C[i] != ' ') {
      ans[i] = C[i];
    } else if ((i == 0) && (N != 1)) {
      ans[i] = '1';
    } else {
      ans[i] = '0';
    }
    cout << ans[i];
  }
  return 0;
}
