#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  if (m == 0) {
    for (int i = 0; i < (n); i++) {
      cout << 1;
    }
  }
  vector<P> sc(m);
  if (m != 0) {
    for (int i = 0; i < (m); i++) {
      cin >> sc[i].first >> sc[i].second;
    }
    for (int i = 0; i < (m); i++) {
      if (sc[i].first == 1 && sc[i].second == 0) {
        cout << -1 << endl;
        return 0;
      }
    }
    for (int i = 0; i < (m); i++) {
      for (int j = 0; j < (m); j++) {
        if (i != j && sc[i].first == sc[j].first &&
            sc[i].second != sc[j].second) {
          cout << -1 << endl;
          return 0;
        }
      }
    }
    sort((sc).begin(), (sc).end());
  }
  string ans = "";
  int count = 1, idx = 0;
  for (auto p : sc) {
    while (count < p.first) {
      cout << 1;
      count++;
      if (count > n) {
        cout << endl;
        return 0;
      }
    }
    cout << p.second;
    count++;
    if (count > n) break;
  }
  cout << endl;
  return 0;
}
