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