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