#include <bits/stdc++.h>
int N, M;
std::string S;
int main() {
  scanf("%d%d", &N, &M);
  for (int i = (0); i < (N); ++i) S += "*";
  bool fl = false;
  for (int i = (0); i < (M); ++i) {
    int s, c;
    scanf("%d%d", &s, &c);
    if (S[s - 1] != '*' && S[s - 1] != c + '0') fl = true;
    S[s - 1] = c + '0';
  }
  if (fl || S[0] == '0') {
    puts("-1");
    return 0;
  }
  for (int i = (0); i < (N); ++i) {
    if (S[i] == '*') S[i] = i ? '0' : '1';
    printf("%c", S[i]);
  }
  puts("");
  return 0;
}
