#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  string s = "aaa";
  if (n == 1) s = "a";
  if (n == 2) s == "aa";
  for (long long i = 0; i < (long long)m; i++) {
    long long a, b;
    cin >> a >> b;
    if (s[a - 1] != 'a' && s[a - 1] != b + '0') {
      s = "-1";
      break;
    }
    s[a - 1] = b + '0';
  }
  if (n != 1 && s[0] == '0') s = "-1";
  for (long long i = 0; i < (long long)n; i++) {
    if (n == 1 && s[i] == 'a')
      s[i] = '1';
    else if (s[i] == 'a')
      s[i] = '0';
  }
  cout << s << endl;
}
