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