#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, M;
  cin >> N >> M;
  map<int, int> ma;
  bool flag = false;
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (s == 0 && c == 0) flag = true;
    auto f = ma.find(s);
    if (f == ma.end()) {
      ma[s] = c;
    } else {
      if ((*f).second != c) {
        flag = true;
      }
    }
  }
  if (flag) {
    cout << -1 << endl;
    return 0;
  }
  string ans(N, '0');
  ans[0] = '1';
  for (auto m : ma) {
    ans[m.first] = m.second + '0';
  }
  cout << ans << endl;
  return 0;
}
