use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        sc: [(usize, usize); m],
    }

    let mut ansvec = vec![0; n];
    for (s, c) in sc {
        let curr_c = ansvec[s-1];
        if (curr_c!=c && curr_c!=0) || (s==1 && c==0) {
            println!("-1");
            return;
        } else { ansvec[s-1] = c }
    }

    if ansvec[0]==0 && n>1 { ansvec[0] = 1; }
    let ans = ansvec.iter().map(|d| d.to_string()).collect::<String>();
    println!("{}", ans);
}
