#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  for (int i = 0; i < m; i++) {
    cin >> a.at(i) >> b.at(i);
  }
  string num = "";
  for (int i = 0; i < n; i++) {
    num.push_back('a');
  }
  for (int i = 0; i < m; i++) {
    int dg = a.at(i);
    if (dg > n) {
      cout << -1 << endl;
      return 0;
    } else if (num.at(dg - 1) == 'a') {
      num.at(dg - 1) = '0' + b.at(i);
    } else if (num.at(dg - 1) != '0' + b.at(i)) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (num.at(0) == '0' && n != 1) {
    cout << -1 << endl;
    return 0;
  } else if (num.at(0) == 'a') {
    num.at(0) = '1';
  }
  for (char& c : num) {
    if (c == 'a') {
      c = '0';
    }
  }
  cout << num << endl;
  return 0;
}
