#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  pair<int, int> k[m];
  int x, y;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    k[i] = make_pair(x, y);
  }
  string s = "";
  for (int i = 0; i < n; i++) {
    s += 'a';
  }
  bool ok = true;
  sort(k, k + m);
  for (int i = 0; i < m - 1; i++) {
    if (k[i].first == k[i + 1].first && k[i].second != k[i + 1].second) {
      ok = false;
      break;
    }
    s[k[i].first - 1] = k[i].second + '0';
  }
  s[k[m - 1].first - 1] = k[m - 1].second + '0';
  if (s[0] == '0') {
    ok = false;
  } else if (s[0] == 'a') {
    s[0] = '1';
  }
  if (!ok) {
    cout << -1 << endl;
  } else {
    for (int i = 1; i < s.length(); i++) {
      if (s[i] == 'a') {
        s[i] = '0';
      }
    }
    cout << s;
  }
}
