#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
int main() {
  int n, m;
  cin >> n >> m;
  string str;
  for (int i = 0; i < n; ++i) str += '?';
  bool ok = true;
  for (int i = 0; i < m; ++i) {
    int s, c;
    cin >> s >> c;
    if (s == 1 && c == 0) ok = false;
    if (str[s - 1] != '?' && str[s - 1] != (char)('0' + c)) ok = false;
    str[s - 1] = (char)('0' + c);
  }
  for (int i = 0; i < n; ++i) {
    if (str[i] == '?') {
      if (i == 0)
        str[i] = '1';
      else
        str[i] = '0';
    }
  }
  if (ok)
    cout << str << endl;
  else
    cout << -1 << endl;
  return 0;
}
