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