use proconio::{fastout, input};

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

    let ten: i64 = 10;

    if m > 0 {
        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 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");
        }
    } else {
        if n == 1 {
            println!("0");
        } else {
            println!("{}", ten.pow((n - 1) as u32))
        }
    }
}
