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