#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  pair<int, int> d[m];
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    d[i] = make_pair(s, c);
  }
  sort(d, d + m);
  char ans[n];
  for (int i = 0; i < n; i++) ans[i] = '0';
  if (n != 1 && d[0].first == 1 && d[0].second == 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < m - 1; i++) {
    if (d[i].first == d[i + 1].first && d[i].second != d[i + 1].second) {
      cout << -1 << endl;
      return 0;
    }
    ans[d[i].first - 1] = d[i].second + '0';
  }
  ans[d[m - 1].first - 1] = d[m - 1].second + '0';
  ;
  if (ans[0] == '0') ans[0] = '1';
  for (int i = 0; i < n; i++) cout << ans[i];
  cout << endl;
  return 0;
}
