let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let ds = Array.make n None in
  try
    for i = 0 to m - 1 do
      Scanf.scanf "%d %d\n" @@ fun s c ->
        match ds.(s - 1) with
        | None ->
            if s = 1 && c = 0 then raise Not_found;
            ds.(s - 1) <- Some c
        | Some c' -> if c <> c' then raise Not_found
    done;

    Array.iteri (fun i -> function
      | None -> print_string @@ if i = 0 then "1" else "0"
      | Some d -> print_int d) ds;
    print_newline ()
  with Not_found -> print_endline "-1"