#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n + 1];
  memset(a, -1, sizeof a);
  while (m--) {
    int s, c;
    cin >> s >> c;
    --s;
    if (a[s] != -1 && a[s] != c) {
      cout << -1;
      return 0;
    }
    a[s] = c;
  }
  if (a[0] == 0 && n > 1) {
    cout << -1;
    return 0;
  }
  if (a[0] == -1) a[0] = 1;
  for (int i = 0; i < n; i++) cout << max(a[i], 0);
  return 0;
}
