import sequtils, strutils let a: seq[int] = stdin.readline.split.map(parseInt) var ans: int = 1 for i in 0..2: ans = ans * a[i] mod a[3] echo ans