fn main() {
    proconio::input! {
        n: usize,
        m: usize,
        sc: [(usize,i8);m],
    }
    let mut a=vec![-1;n];
    for (s,c) in sc {
        if s<1 || n<s || (a[s-1]!=-1 && a[s-1]!=c) {
            a[0]=-1;
            break;
        }
        a[s-1]=c;
    }
    if a[0]==-1 || a[0]==0 {
        println!("-1");
        return;
    }
    for a in a.iter_mut() {
        if *a==-1 {
            *a=0;
        }
    }
    println!("{}",itertools::join(a, ""));
}