fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut sc: Vec<(usize, char)> = vec![];
    for _ in 0..m {
        sc.push((read(), read()));
    }

    for i in 0..10_i32.pow(n as u32) {
        // 100
        let ss = format!("{}", i);
        if ss.len() != n {
            continue;
        }
        let ss: Vec<char> = ss.chars().collect();
        // s[0] = 1, s[1] = 0, s[2] = 0
        if sc.iter().all(|&(s, c)| ss[s - 1] == c) {
            println!("{}", i);
            return;
        }
    }
    println!("-1");
}

use std::io::stdin;
use std::io::Read;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let token: String = cin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
