(function Main(input){
	var input = input.split('\n'),
		_ = input[0].split(' '),
		N = Number(_[0]),
		M = Number(_[1]),
		arr = new Array(N),
		flag = true;

	input.splice(0,1);

	for(var i=0; i<M; i++){
		var _ = input[i].split(' '),
			s = _[0],
			c = _[1];

		if(arr[s-1] && arr[s-1] != c){ flag = false; break; }
		arr[s-1] = c;
	}

	if(N >= 2 && arr[0] === '0'){ flag = false; }

	if(flag){
		for(var i=0; i<arr.length; i++){
			if(!arr[0]){
				arr[0] = 1;

			}else if(!arr[i]){
				arr[i] = 0;
			}
		}
		console.log(arr.join(''));

	}else{
		console.log(-1);
	}
})(require("fs").readFileSync("/dev/stdin","utf8"));