#![allow(unused_imports)]pub mod pcl{pub mod stdin{use std::io::prelude::*;use std::io::stdin;use std::str::FromStr;pub fn read_line()->String{let mut s=String::new();stdin().read_line(&mut s).unwrap();s.trim().to_string()}pub fn read<T:FromStr>()->T{read_from(stdin())}pub fn read_token()->String{read_token_from(stdin())}pub fn read_ascii()->char{read_ascii_from(stdin())}pub fn read_from<R:Read,T:FromStr>(read:R)->T{read_token_from(read).parse().unwrap_or_else(|_|panic!("failed to parse a value"))}pub fn read_token_from<R:Read>(read:R)->String{read.bytes().flat_map(|x|x.map(|x|x as char)).skip_while(|x|x.is_whitespace()).take_while(|x|!x.is_whitespace()).collect()}pub fn read_ascii_from<R:Read>(read:R)->char{read.bytes().flat_map(|x|x.map(|x|x as char)).skip_while(|x|x.is_whitespace()).next().expect("failed to get a next character")}}}
use pcl::stdin::*;
fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut res = vec![0; n];
    for _ in 0..m {
        let s: usize = read();
        let mut c: u8 = read();
        c += b'0';
        if res[s - 1] != 0 && res[s - 1] != c {
            println!("-1");
            return;
        }
        res[s - 1] = c;
    }
    for i in 0..n {
        if res[i] == 0 {
            if i == 0 {
                res[i] = b'1';
            } else {
                res[i] = b'0';
            }
        }
    }
    if res[0] == b'0' {
        println!("-1");
        return;
    }
    println!("{}", unsafe { String::from_utf8_unchecked(res) });
}

