integer*8::A,B,C,D read *, A,B,C,D print '(i0)', MOD(MOD(MOD(A,D)*B,D)*C,D) end program