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