#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  string s = "";
  for (int asdf = 0; asdf < n; asdf++) {
    s += '?';
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    if (x == 1 && !y) {
      cout << -1 << endl;
      return 0;
    }
    if (s[x - 1] != '?' && s[x - 1] != y + '0') {
      cout << -1 << endl;
      return 0;
    }
    if (s[x - 1] = '?') {
      s[x - 1] = y + '0';
    }
  }
  if (s[0] == '?') s[0] = 1;
  for (int i = 1; i < n; i++) {
    if (s[i] == '?') {
      s[i] = '0';
    }
  }
  cout << s << endl;
}
