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