#include <bits/stdc++.h>
using namespace std;
int main() {
  string s = "";
  bool b = 1;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) s += 'a';
  vector<pair<int, int>> v(m);
  for (int i = 0; i < m; ++i) cin >> v[i].first >> v[i].second;
  sort(v.begin(), v.end());
  for (int i = 0; i < m; ++i) {
    if (s[v[i].first - 1] != 'a' && s[v[i].first - 1] != '0' + v[i].second) {
      s = "-1";
      b = 0;
      break;
    } else
      s[v[i].first - 1] = '0' + v[i].second;
  }
  if (b) {
    if (s[0] == '0') s = "-1";
    for (int i = 0; i < n; ++i) {
      if (i == 0 && s[i] == 'a')
        s[i] = '1';
      else if (s[i] == 'a')
        s[i] = '0';
    }
  }
  cout << s << endl;
  return 0;
}
