#include <bits/stdc++.h>
using namespace std;
int main() {
  map<int, int> mp;
  int N, M;
  bool test = true;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int t, p;
    cin >> t >> p;
    if (mp.find(t) == mp.end() && !(t == 1 && p == 0 && N != 1)) {
      mp[t] = p;
    } else {
      test = false;
    }
  }
  if (test == false) {
    cout << -1 << endl;
    return 0;
  }
  int i = 1;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    if (itr->first != i) {
      while (i != itr->first) {
        if (i = 1) {
          cout << 1;
        } else {
          cout << 0;
        }
      }
    }
    cout << itr->second;
  }
  for (; i <= N; i++) {
    cout << 0;
  }
  cout << endl;
}
