open System type Sol() = member this.Solve() = let A = stdin.ReadLine().Split() |> Array.map int64 A.[0] * A.[1] % A.[3] * A.[2] % A.[3] |> printfn "%d" let mySol = new Sol() mySol.Solve()