use std::io;
use std::str::FromStr;

fn input_tuple() -> (usize, usize) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<usize> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (n, m) = input_tuple();
    let mut ans = vec![10; 3];
    for i in 0..m as usize {
        let (s, c) = input_tuple();
        if ans[s - 1] != 10 && ans[s - 1] != c {
            println!("-1");
            return;
        }
        ans[s-1] = c;
    }
    let mut flag = true;
    for i in 0..n {
        if flag {
            if ans[i] == 10 {
                ans[i] = 1;
            }
            flag = false;
            if ans[i] == 0 {
                println!("-1");
                return;
            }
        } else {
            if ans[i] == 10 {
                ans[i] = 0;
            }
        }
    }
    for a in ans {
        print!("{}", a);
    }
    println!();
}
