use proconio::{fastout, input};

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

    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() {
            // println!("{:?}", sc_i);
            let s = sc_i[0];
            let c = sc_i[1];
            // println!("{}", c.to_string());

            let ns = num.to_string();
            // println!("{}, {}, {}", ns, &ns[s - 1..s], c);

            if s == 1 && c == 0 && n != 1 {
                judge = false;
                break;
            }

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

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

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