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