let [| p; q; y0; p0; q0; y |] = stdin.ReadLine().Split() |> Array.map int let dist = y - y0 let calc1 x0 x = (dist + x0 - 1) % x + 1 let calc2 x0 x = (x0 - (abs dist) % x + x - 1) % x + 1 if dist >= 0 then [| calc1 p0 p; calc1 q0 q |] else [| calc2 p0 p; calc2 q0 q |] |> Array.map string |> String.concat " " |> printfn "%s"