use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize, m: usize, sc: [[usize; 2]; m]};
    let mut isValid = true;

    let ten: i64 = 10;

    for num in ten.pow((n - 1) as u32)..ten.pow(n as u32) {
        let mut judge = true;
        for sc_i in sc.iter() {
            let s = sc_i[0];
            let c = sc_i[1];

            let ns = num.to_string();

            if &ns[s - 1..s] != c.to_string() {
                judge = false;
            }
        }

        if judge {
            println!("{}", num);
            isValid = false;
            break;
        }
    }

    if isValid {
        println!("-1");
    }
}
