import sequtils, strutils let ns = stdin.readLine.split.map parseInt d = ns[3] var ans = 1 for i in 0..2: ans = ans * ns[i] mod d echo ans