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

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .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")
}

fn main() {
    let n: usize = read();
    let m: usize = read();

    let mut si: Vec<usize> = Vec::new();
    let mut ci: Vec<usize> = Vec::new();

    let mut ans: Vec<i32> = (0..n).map(|_| -1).collect();

    for _ in 0..m {
        si.push(read());
        ci.push(read());
    }

    let mut bad_flag = false;
    for i in 0..m {
        let idx = si[i] - 1;
        if ans[idx] == -1 {
            ans[idx] = ci[i] as i32;
        } else if ans[idx] != ci[i] as i32 {
            bad_flag = true;
            break;
        } 
    }

    if n > 1 && ans[0] == 0 {
        bad_flag = true;
    }

    if bad_flag {
        println!("-1");
    } else {
        for i in 0..n {
            if ans[i] == -1 {
                if i == 0 {
                    ans[i] = 1;
                } else {
                    ans[i] = 0;
                }
            }
        }
        let ans: String = ans.into_iter().map(|i| i.to_string()).collect();
        println!("{}", ans);
    }
}
