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