#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<char> C(N, ' ');
  bool ok = true;
  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
      ok = false;
  }
  if (!ok) {
    cout << -1 << endl;
    return 0;
  }
  if (C[0] == '0') {
    cout << -1 << endl;
    return 0;
  }
  vector<char> ans(N, ' ');
  for (int i = 0; i < N; i++) {
    if (C[i] != ' ') {
      ans[i] = C[i];
      continue;
    }
    if (i == 0)
      ans[i] = '1';
    else
      ans[i] = '0';
  }
  for (int i = 0; i < N; i++) cout << ans[i];
  cout << endl;
  return 0;
}
