#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y;
} p[10];
int a[10];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, f = 0, h = 0;
  cin >> n >> m;
  a[1] = 1;
  for (int i = 0; i < m; i++) {
    cin >> p[i].x >> p[i].y;
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      if (p[i].x == p[j].x && p[i].y != p[j].y) f = 1;
    }
    if (p[i].x > n) f = 1;
    if (p[i].x == 1) {
      if (p[i].y == 0) f = 1;
    }
    a[p[i].x] = p[i].y;
  }
  if (n == 1 && m == 0)
    cout << 0 << endl;
  else if (f == 1)
    cout << -1 << endl;
  else if (f == 0) {
    for (int i = 1; i <= n; i++) {
      cout << a[i];
    }
    cout << endl;
  }
  return 0;
}
