fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let mut conditions: Vec<usize> = vec![10; n];
    let m: usize = scan(tokens);
    for _ in 0..m {
        let s: usize = scan(tokens);
        let s = s - 1;
        let c: usize = scan(tokens);
        if n > 1 && s == 0 && c == 0 {
            println!("-1");
            return;
        } else if conditions[s] == 10 {
            conditions[s] = c;
        } else if conditions[s] != c {
            println!("-1");
            return;
        }
    }
    for i in 0..n {
        if conditions[i] == 10 {
            if i == 0 {
                conditions[i] = 1;
            } else {
                conditions[i] = 0;
            }
        }
        print!("{}", conditions[i]);
    }
    println!("");
}
