#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int s, c;
  vector<int> d(n, -1);
  for (int i = 0; i < m; ++i) {
    cin >> s >> c;
    if ((d.at(s - 1) == -1 || d.at(s - 1) == c) && !(s == 1 && c == 0))
      d.at(s - 1) = c;
    else {
      printf("-1\n");
      return 0;
    }
  }
  if (d.at(0) == -1)
    printf("1");
  else
    printf("%d", d.at(0));
  for (int i = 1; i < n; ++i) {
    if (d.at(i) == -1)
      printf("0");
    else
      printf("%d", d.at(i));
  }
  printf("\n");
  return 0;
}
