#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, f = 0;
  vector<int> s;
  cin >> n >> m;
  vector<pair<int, int> > v;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    v.push_back(make_pair(x, y));
  }
  for (int i = 0; i < m - 1; i++) {
    if (v[i].first == v[i + 1].first) {
      f = 1;
    }
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    int j = 0;
    if (i == 0 && v[j].first == 1) {
      if (v[j].second == 0) {
        f = 1;
      } else {
        s.push_back(v[j].second);
      }
      j++;
    } else if (i == 0) {
      s.push_back(1);
    } else if (v[j].first == i + 1) {
      s.push_back(v[j].second);
      j++;
    } else {
      s.push_back(0);
    }
  }
  if (f == 1) {
    cout << "-1" << endl;
  } else {
    for (int i = 0; i < n; i++) {
      cout << s[i];
    }
  }
  cout << endl;
  return 0;
}
