let n, m = Scanf.scanf "%d %d\n" @@ fun a b -> a, b let op = Scanf.scanf "%s " (fun a -> a) let brr = Array.to_list (Array.init m (fun _ -> Scanf.scanf "%d " (fun x -> x))) let arr = Array.to_list (Array.init n (fun _ -> Scanf.scanf "%d\n" (fun x -> x))) let h = if op = "+" then (fun x y -> x + y) else (fun x y -> x * y) let rec g h a blst = match blst with | [] -> [] | head :: tail -> (h head a) :: g h a tail let rec f alst blst = match alst with | [] -> [] | head :: tail -> g h head blst :: f tail blst let ans = f arr brr let rec string_of_list lst = match lst with | [] -> "" | head :: tail -> (string_of_int head) ^ " " ^ string_of_list tail let () = List.iter (fun lst -> print_endline (string_of_list lst)) ans