#include <bits/stdc++.h>
int main(int argc, char const *argv[]) {
  int n, m;
  int s[7], c[7];
  int beg = 1, keta = 1, ans = 0;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n - 1; ++i) beg *= 10;
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &s[i], &c[i]);
    keta = 1;
    for (int j = 0; j < s[i] - 1; ++j) keta *= 10;
    ans += (keta * c[i]);
  }
  if (beg <= ans && ans < beg * 10)
    printf("%d\n", ans);
  else
    puts("-1");
  return 0;
}
