func main() var n: int :: cui@inputInt() var k: int :: cui@inputInt() var m: int :: cui@inputInt() var p: []int :: #[n]int var e: []int :: #[n]int var a: []int :: #[n]int var h: []int :: #[n]int for i(0, n - 1) do p[i] :: cui@inputInt() end for for i(0, n - 1) do e[i] :: cui@inputInt() end for for i(0, n - 1) do a[i] :: cui@inputInt() end for for i(0, n - 1) do h[i] :: cui@inputInt() end for do p.sort() do e.sort() do a.sort() do h.sort() var x: [][]int :: #[n, 4]int for i(0, n - 1) do x[i][0] :: p[i] do x[i][1] :: e[i] do x[i][2] :: a[i] do x[i][3] :: h[i] end for var ans: int :: 0 for i(0, n - 1) do ans :+ math@modPow(x[i].max() - x[i].min(), k, m) end for do ans :% m do cui@print("\{ans}\n") end func