use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let (n, m) = read_touple::<usize>();
    let mut sc = vec![];
    for _ in 0..m {
      let (s, c) = read_touple::<usize>();
      sc.push((s-1, c));
    }
    let num = if n == 1 {
       10
    } else if n == 2 {
       100
    } else {
      1000
    };

    for i in 0..num {
      let xs: Vec<usize> = i.to_string().chars().map(|x| x as usize - '0' as usize).collect();
      let mut check = true;
      let d = digit(i);
      for &(s, c) in &sc {
        check = check && get(&xs, s, c);
      }

      if check && d == n {
         println!("{}", i);
         return
      }
    }

    println!("-1");
}

fn get(xs: &Vec<usize>, s: usize, c: usize) -> bool {
  if xs.len() <= s {
     return false
  }
    xs[s] == c
}

fn digit(x: usize) -> usize {
  let mut res = 0;
  let mut x = x;
  while x > 0 {
    x /= 10;
    res += 1;
  }
  res
}