let (n, m) = Scanf.sscanf (read_line ()) "%d %d" @@ fun n m -> (n, m)
let sc = Array.init m @@ fun _ -> Scanf.sscanf (read_line ()) "%d %d" @@ fun s c -> (s - 1, c)

let ans = Array.make n (-1)

let () =
  Array.iter (fun (s, c) ->
    if ans.(s) = -1 || ans.(s) = c then ans.(s) <- c
    else begin
      print_endline "-1";
      exit 0
    end
  ) sc;
  if n = 1 then
    Printf.printf "%d\n" @@ if ans.(0) = -1 then 0 else ans.(0)
  else begin
    if ans.(0) = 0 then begin
      print_endline "-1";
      exit 0
    end;
    for i = 0 to n - 1 do
      if ans.(i) = -1 then ans.(i) <- if i = 0 then 1 else 0
    done;
    Array.iter print_int ans;
    print_newline ()
  end
