module IntSet = Set.Make (struct
  type t = int
  let compare = compare
end)

let () = Scanf.scanf "%d" @@ function
  | 3 -> print_endline "2 5 63\n"
  | 4 -> print_endline "2 5 20 63\n"
  | 5 -> print_endline "2 5 20 30 63\n"
  | n ->
      let s =
        IntSet.of_list @@
        Array.to_list @@
        Array.init n @@ fun i ->
          i / 4 * 6 + [| 2; 3; 4; 6 |].(i mod 4) in
      IntSet.iter (Printf.printf "%d ")
        begin match IntSet.fold (fun x y -> x * y mod 6) s 1 with
        | 0 -> s
        | 2 -> IntSet.add ((n + 3) / 4 * 6) @@ IntSet.remove 8 s
        | 3 -> IntSet.add ((n + 3) / 4 * 6) @@ IntSet.remove 9 s
        | 5 -> IntSet.add ((n + 3) / 4 * 6 + 4) @@ IntSet.remove 9 s
        end;
      print_newline ()