#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  string second;
  for (long long i = 0; i < n; i++) second.push_back('a');
  bool tf = 1;
  for (long long i = 0; i < m; i++) {
    long long s, c;
    cin >> s >> c;
    s--;
    if (second[s] != 'a') {
      char cc = '0' + c;
      if (second[s] != cc) tf = 0;
    } else
      second[s] = '0' + c;
  }
  for (long long i = 0; i < second.size(); i++) {
    if (second[i] == 'a' && i == 0)
      second[i] = '1';
    else if (second[i] == 'a')
      second[i] = '0';
  }
  if (second[0] == '0' && n > 1)
    cout << -1;
  else if (tf)
    cout << second;
  else
    cout << -1;
}
