let [|n; m; k|] = stdin.ReadLine().Split " " |> Array.map int64 let x = stdin.ReadLine().Split " " let op = x.[0] let b = x.[1..] |> Array.map int64 let a = [| for _ in 0..(n-1L |> int) -> stdin.ReadLine () |> int64 |] if op = "+" then ((a |> Array.sum |> ((*)m)) + (b |> Array.sum |> ((*)n))) % k else let f = Array.reduce (fun x y -> (x + y) % (int64 k)) ((a |> f) * (b |> f)) % (int64 k) |> printfn "%d"