#include <bits/stdc++.h>
const long INF = (1l << 30);
const long LINF = (1l << 60);
long n, m;
int main() {
  scanf("%ld%ld", &n, &m);
  std::string ans(n, 'a');
  for (int i = 0; i < m; i++) {
    long s;
    long c;
    scanf("%ld%ld", &s, &c);
    s--;
    if (ans[s] == 'a' || ans[s] == c + '0') {
      ans[s] = c + '0';
    } else {
      printf("-1\n");
      return 0;
    }
  }
  if (ans[0] == '0' && n != 1) {
    printf("-1\n");
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (ans[i] == 'a') {
      if (i == 0) {
        ans[i] = '1';
      } else {
        ans[i] = '0';
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}
