#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, s;
  char c;
  cin >> n >> m;
  string ans = "";
  for (int i = 0; i < n; i++) ans.push_back('x');
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    if (ans[s - 1] == 'x' || ans[s - 1] == c)
      ans[s - 1] = c;
    else {
      cout << -1 << endl;
      return 0;
    }
  }
  if (ans[0] == 'x') ans[0] = '1';
  if (n > 1 && ans[0] == '0') {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    cout << (ans[i] == 'x' ? '0' : ans[i]);
  }
  cout << endl;
}
