use std::io::*;
use std::str::FromStr;

fn main() {
	let n: usize = read();
	let m: usize = read();
	let mut v = vec![0; n];
	let (mut s, mut c): (usize, i8);
	for _ in 0..m {
		s = read();
		c = read();
		if (s, c) == (1, 0) {
			v[0] = -1;
		} else if v[s-1] == 0 {
			v[s-1] = c;
		} else if v[s-1] != c {
			v[0] = -1;
		}
	}
	if v[0] == 0 {
		v[0] = 1;
	}
	if v[0] == -1 {
		print!("-1");
	} else {
		for i in &v {
			print!("{}", i);
		}
	}
			println!("");
}



fn read<T: FromStr>() -> T {
	let stdin = stdin();
	let stdin = stdin.lock();
	let token: String = stdin
		.bytes()
		.map(|c| c.expect("failed to read char") as char)
		.skip_while(|c| c.is_whitespace())
		.take_while(|c| !c.is_whitespace())
		.collect();
	token.parse().ok().expect("failed to parse token")
}

