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