use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<usize>();
    let (n, m) = (line[0], line[1]);
    let mut v: Vec<i32> = vec![-1;n];

    for _ in 0..m{
        let line = read_as_vec::<i32>();
        let (s, c) = (line[0] as usize-1, line[1]);
        if s == 0 && c == 0{
            println!("-1");
            return;
        }

        if v[s] != -1 && v[s] != c{
            println!("-1");
            return;
        }
        v[s] = c;
    }

    print!("{}", cmp::max(v[0], 1));
    for i in 1..n{
        if v[i] < 0{
            print!("0");
        }else{
            println!("{}", v[i]);
        }
    }
    println!("");
}
