Problem: On a number line there are n balls. At time moment 0 for each ball the following data is known: its coordinate xi, speed vi (possibly, negative) and weight mi. The radius of the balls can be ignored.

The balls collide elastically, i.e. if two balls weighing m1 and m2 and with speeds v1 and v2 collide, their new speeds will be: 

<image>.

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: xi, vi, mi (1 ≤ |vi|, mi ≤ 100, |xi| ≤ 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

Solution (in JAVA):

Solution:
import java.util.Scanner;


public class E {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        double[]x = new double[n+1],v = new double[n+1];
        int[]m = new int[n+1];
        for (int i = 1; i <= n; i++) {
            x[i] = sc.nextInt();
            v[i] = sc.nextInt();
            m[i] = sc.nextInt();
        }
        double INF = 1e9;
        double cur_time = 0;
        while (true) {
            double min = INF;
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= n; j++) {
                    if (i==j || x[i] > x[j] || Math.abs(x[i]-x[j]) < 1e-8)
                        continue;
                    if (v[i] <= 0 && v[j] >= 0)
                        continue;
                    double time = 0;
                    boolean f = false;
                    if (v[i] >= 0 && v[j] <= 0) {
                        if (Math.abs(v[i]-v[j]) > 1e-8) {
                            time = (x[j]-x[i])/(v[i]-v[j]);
                            f = true;
                        }
                    }
                    else {
                        if (v[i] >= 0 && v[j] >= 0) {
                            if (v[i] +1e-8> v[j] && Math.abs(v[i]-v[j]) > 1e-8) {
                                time = (x[j]-x[i])/Math.abs(v[i]-v[j]);
                                f = true;
                            }
                        }
                        else {
                            if (-v[j]+1e-8 > -v[i] && Math.abs(-v[j]+v[i]) > 1e-8) {
                                time = (x[j]-x[i])/Math.abs(-v[j]+v[i]);
                                f = true;
                            }
                        }
                    }
                    if (f && time < min) {
                        min = time;
                    }
                }
            }
            boolean end = false;
            if (min==INF || cur_time+min >= t) {
                end = true;
                min = t-cur_time;
            }
            for (int i = 1; i <= n; i++) {
                x[i] += v[i]*min;
            }
            if (end)
                break;
            for (int i = 1; i <= n; i++) {
                for (int j = i+1; j <= n; j++) {
                    if (Math.abs(x[i]-x[j]) < 1e-8) {
                        double v1 = v[i], v2 = v[j];
                        v[i] = ((m[i]-m[j])*v1+2*m[j]*v2)/(m[i]+m[j]);
                        v[j] = ((m[j]-m[i])*v2+2*m[i]*v1)/(m[i]+m[j]);
                    }
                }
            }
            cur_time += min;
        }
        for (int i = 1; i <= n; i++) {
            System.out.println(x[i]);
        }
    }
}/*
2 9
3 4 5
0 7 8

3 10
1 2 3
4 -5 6
7 -8 9
*/