#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int> > input;
  for (int i = 0; i < (M); ++i) {
    pair<int, int> p;
    cin >> p.first >> p.second;
    input.push_back(p);
  }
  string res = "";
  for (int i = 0; i < (N); ++i) {
    res += "a";
  }
  for (int i = 0; i < (M); ++i) {
    if (res[input[i].first - 1] != 'a' &&
        res[input[i].first - 1] != (char)(input[i].second + '1' - 1)) {
      cout << -1 << endl;
      return 0;
    }
    res[input[i].first - 1] = (char)(input[i].second + '1' - 1);
  }
  for (int i = 0; i < (N); ++i) {
    if (res[i] == 'a') {
      if (i == 0) {
        res[i] = '1';
      } else {
        res[i] = '0';
      }
    }
  }
  if (res[0] == '0') {
    cout << -1 << endl;
    return 0;
  }
  cout << res << endl;
}
