#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> pa(m);
  vector<int> v(n);
  v[0] = 1;
  for (int i = 0; i < m; i++) {
    cin >> pa[i].first >> pa[i].second;
  }
  bool ok = true;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      if (pa[i].first == pa[j].first && pa[i].second != pa[j].second) {
        ok = false;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (pa[i].first == 1 && pa[i].second == 0) {
      ok = false;
      break;
    }
  }
  if (ok) {
    for (int i = 0; i < m; i++) {
      v[pa[i].first - 1] = pa[i].second;
    }
    for (int i = 0; i < n; i++) cout << v[i];
  } else
    cout << -1;
  return 0;
}
