#include <bits/stdc++.h>
using namespace std;
long long get() {
  char c = getchar();
  long long x = 0LL;
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') {
    x *= 10LL;
    x += (c - '0');
    c = getchar();
  }
  return x;
}
int n, m;
int s[10], c[10], a[10];
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  memset(a, -1, sizeof(a));
  bool f = true;
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
    if (a[s[i] - 1] == -1) a[s[i] - 1] = c[i];
    if (a[s[i] - 1] != c[i]) {
      f = false;
    }
    if (s[i] == 1 && c[i] == 0) {
      f = false;
    }
  }
  if (!f) {
    cout << -1;
    return 0;
  }
  if (n == 1 && a[0] == -1) {
    cout << 0;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (a[i] != -1)
      cout << a[i];
    else {
      if (i == 0)
        cout << 1;
      else
        cout << 0;
    }
  }
  return 0;
}
