Under construction

Still being built. Things may change

Balls

Interview

Time limit2sMemory limit1024 MB

Summary
Given two balls with integer positions and velocities that swap velocities on each elastic collision, print each ball's position and velocity at time T.
Level

Easy3 of 10

Topics
Math, Simulation
Solved
No attempts yet

Statement

A wicked wizard named Liahi placed two infinitely small balls of equal mass at different points with integer coordinates x1x_1 and x2x_2 on the real axis. At time 00 he gave the ii-th ball a velocity viv_i and watched them move. The collisions are perfectly elastic. Because the masses are equal, after a collision each ball moves with the velocity of the other ball and takes over its direction of motion.

The wizard wants a program that prints the state of both balls at time TT. If the program is wrong, he will put you inside one of these balls.

Input

The first line contains x1x_1 and v1v_1. The second line contains x2x_2 and v2v_2. The third line contains TT. All numbers are integers with absolute values not exceeding 10410^4.

Output

Print two lines. The first line contains the position and velocity of the first ball at time TT. The second line contains the position and velocity of the second ball at time TT. Round every value to the nearest integer. Separate the numbers in each line with a space. The coordinates of the balls are guaranteed to differ at time 00 and at time TT.

Examples2

  1. Example 1

    Input
    1 2
    2 2
    5
    
    Expected output
    11 2
    12 2
    
  2. Example 2

    Input
    8 2
    12 -2
    10
    
    Expected output
    -8 -2
    28 2