#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
static const long long INF = 1e15;
int main(void) {
  long long n, m;
  cin >> n >> m;
  vector<set<long long>> ss(n);
  for (long long i = 0; i < m; i++) {
    long long s, c;
    cin >> s >> c;
    ss[s - 1].insert(c);
  }
  for (long long i = 0; i < n; i++) {
    if (ss[i].size() >= 2) {
      cout << -1 << endl;
      return 0;
    }
  }
  vector<long long> r;
  for (long long i = 0; i < n; i++) {
    if (ss[i].size() == 0) {
      if (i == 0)
        r.push_back(1);
      else
        r.push_back(0);
    } else {
      long long t = *ss[i].begin();
      if (i == 0 && t == 0) {
        cout << -1 << endl;
        return 0;
      }
      r.push_back(t);
    }
  }
  for (long long i = 0; i < n; i++) cout << r[i];
  cout << endl;
  return 0;
}
