#include <bits/stdc++.h>
using namespace std;
int n, m;
char s[100];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) s[i] = '@';
  for (int i = 1; i <= m; i++) {
    int p;
    char c;
    scanf("%d %c", &p, &c);
    if (s[p] != '@' && s[p] != c) {
      puts("-1");
      return 0;
    }
    s[p] = c;
  }
  if (s[1] == '0') {
    puts("-1");
    return 0;
  }
  if (s[1] == '@') s[1] = '1';
  for (int i = 1; i <= n; i++)
    if (s[i] == '@') s[i] = '0';
  puts(s + 1);
  return 0;
}
