func main() var ss: [][]char do ss :: cui@input().split(" ") var n: int :: ss[0].toInt(&) var m: int :: ss[1].toInt(&) var k: int :: ss[2].toInt(&) do ss :: cui@input().split(" ") var op: char :: ss[0][0] var bSum: int :: 0 for i(1, m) do bSum :+ ss[i].toInt(&) do bSum :% k end for var aSum: int :: 0 for i(0, n - 1) do aSum :+ cui@input().toInt(&) do aSum :% k end for var ans: int :: op = '+' ?(aSum * m + bSum * n, aSum * bSum) do ans :% k do cui@print("\{ans}\n") end func