#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > mv(m);
  int c = 0;
  for (int i = 0; i < m; i++) {
    cin >> mv[i].first >> mv[i].second;
    if (mv[i].first == 1 && mv[i].second == 0) c++;
  }
  if (c && n > 1) {
    cout << -1 << endl;
    return 0;
  }
  sort(mv.begin(), mv.end());
  for (int i = 1; i < m; i++) {
    if (mv[i].first == mv[i - 1].first && mv[i].second != mv[i - 1].second) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (c) {
    cout << 0 << endl;
    return 0;
  }
  int lc = 1;
  if (mv[0].first == 1) {
    cout << mv[0].second;
  } else
    cout << 1;
  for (int i = 0; i < m; i++) {
    while (lc < mv[i].first - 1) {
      lc++;
      cout << 0;
    }
    if (lc == mv[i].first - 1) {
      lc++;
      cout << mv[i].second;
    }
  }
  while (lc < n) {
    cout << 0;
    lc++;
  }
  cout << endl;
  return 0;
}
