#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
//use proconio::marker::Chars;
use proconio::marker::Usize1;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
//use std::cmp::*;
//use std::num;

fn main() {
    input! {
        N:usize,M:usize,SC:[(Usize1,char);M]
    }
    let mut ans = vec!['_'; N];
    for &(s, c) in SC.iter() {
        // println!("{:?},{},{}", ans, s, c);
        if ans[s] != '_' && ans[s] != c {
            println!("-1");
            return;
        }
        ans[s] = c;
    }
    if ans[0] == '0' {
        println!("-1");
        return;
    }
    if ans[0] == '_' {
        ans[0] = '1';
    }
    for &c in ans.iter() {
        if c == '_' {
            print!("0");
        } else {
            print!("{}", c);
        }
    }
}
