#include <bits/stdc++.h>
using namespace std;
int digits(int n) { return (int)floor(log10(n) + 1); }
int main(int argc, char **argv) {
  int n = 0, m = 0, num = 0, s = 0, c = 0;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d %d", &s, &c);
    if (digits(num) >= s)
      num = (c * (int)pow(10, n - s)) + (num % (int)pow(10, n - s));
    else
      num += c * (int)pow(10, n - s);
  }
  if (digits(num) == n)
    printf("%d\n", num);
  else
    printf("-1\n");
  return 0;
}
