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