Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

The problem statement has recently been changed. View the changes.

×
E. Collisions

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputOn a number line there are *n* balls. At time moment 0 for each ball the following data is known: its coordinate *x*_{i}, speed *v*_{i} (possibly, negative) and weight *m*_{i}. The radius of the balls can be ignored.

The balls collide elastically, i.e. if two balls weighing *m*_{1} and *m*_{2} and with speeds *v*_{1} and *v*_{2} collide, their new speeds will be:

Your task is to find out, where each ball will be *t* seconds after.

Input

The first line contains two integers *n* and *t* (1 ≤ *n* ≤ 10, 0 ≤ *t* ≤ 100) — amount of balls and duration of the process. Then follow *n* lines, each containing three integers: *x*_{i}, *v*_{i}, *m*_{i} (1 ≤ |*v*_{i}|, *m*_{i} ≤ 100, |*x*_{i}| ≤ 100) — coordinate, speed and weight of the ball with index *i* at time moment 0.

It is guaranteed that no two balls have the same coordinate initially. Also each collision will be a collision of not more than two balls (that is, three or more balls never collide at the same point in all times from segment [0;*t*]).

Output

Output *n* numbers — coordinates of the balls *t* seconds after. Output the numbers accurate to at least 4 digits after the decimal point.

Examples

Input

2 9

3 4 5

0 7 8

Output

68.538461538

44.538461538

Input

3 10

1 2 3

4 -5 6

7 -8 9

Output

-93.666666667

-74.666666667

-15.666666667

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/29/2020 07:55:37 (h2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|