#include <bits/stdc++.h>
const int N = 5e5 + 10;
const double eps = 0.00000001;
const long long mod = 1e18 + 7;
using namespace std;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int s[100];
int main() {
  memset(s, -1, sizeof s);
  int n = read(), m = read();
  int a, b;
  for (int i = 1; i <= m; ++i) {
    cin >> a >> b;
    if (s[a] == -1)
      s[a] = b;
    else if (s[a] != b)
      return puts("-1"), 0;
  }
  if (s[1] == 0) return puts("-1"), 0;
  if (s[1] == -1) s[1] = 1;
  for (int i = 1; i <= n; ++i) {
    cout << (s[i] == -1 ? 0 : s[i]);
  }
}
