#include <stdio.h>
int n, m, s, c, e;
int a[10];
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i <= n; i++) {
		a[i] = 10;
	}
	for (int i = 0; i < m; i++) {
		scanf("%d%d", &s, &c);
		if (s == 1 && c == 0 && n != 1)e = 1;
		if (a[s] != 10 && a[s] != c)e = 1;
		a[s] = c;
	}
	if (e)printf("-1\n");
	else {
		for (int i = 1; i <= n; i++) {
			if (a[i] == 10 && !(i == 1 && n != 1))a[i] = 0;
			if (i == 1 && a[i] == 10 && n != 1)a[i] = 1;
			printf("%d", a[i]);
		}
		printf("\n");
	}
}