use std::io::*;
use std::i64;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
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")
}


//main function
fn main() {
    let n: usize = read();
    let m: i64 = read();
    let mut v: Vec<i64> = Vec::with_capacity(n+1);
    let mut flag: Vec<bool> = Vec::with_capacity(n+1);
    unsafe{
	v.set_len(n+1);
	flag.set_len(n+1);
    }
    for i in 0..n+1{
	if i == 1 && n!=1{
	    v[i as usize] = 1;
	}
	v[i as usize] = 0;
	flag[i as usize] = true;
    }
    for _i in 0..m{
	let s: usize = read();
	let m: i64 = read();
	if !flag[s] && v[s] != m{
	    println!("-1");
	    return;
	}
	if s==1 && m==0{
	    println!("-1");
	    return;
	}
	v[s] = m;
	flag[s] = false;
    }
    for i in 1..n+1 {
	print!("{}",v[i as usize]);
    }
    println!("");
    
}
