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.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.StreamTokenizer;
import java.io.Writer;*/
import java.io.*;

public class Main {
    class A{
        double x,v,m; A(int x, int v, int m){this.x=x;this.v=v;this.m=m;} A(){}
    }
    static class MJ{
        static class ArrEl{
            public static int i, v;
            ArrEl(){}
            ArrEl(int index, int value){
                i = index; v = value;
            }
            @SuppressWarnings("static-access")
            public static ArrEl getMax(int a[]){
                ArrEl m = new ArrEl(Integer.MIN_VALUE,Integer.MIN_VALUE);
                for(int i=0; i<a.length; i++)
                if(a[i]>m.v){m.v=a[i];m.i=i;}
                return m;
            }
            @SuppressWarnings("static-access")
            public static ArrEl getMin(int a[]){
                ArrEl m = new ArrEl(Integer.MAX_VALUE,Integer.MAX_VALUE);
                for(int i=0; i<a.length; i++)
                if(a[i]<m.v){m.v=a[i];m.i=i;}
                return m;
            }
        }
    }
    public static void main(String[] args) throws IOException {
        new Main().run();
    }
    StreamTokenizer in; PrintWriter out; boolean oj; BufferedReader br;

    void init() throws IOException {
        oj = System.getProperty("ONLINE_JUDGE") != null;
        Reader reader = oj ? new InputStreamReader(System.in) : new FileReader("input.txt");
        Writer writer = oj ? new OutputStreamWriter(System.out) : new FileWriter("output.txt");
        br = new BufferedReader(reader);
        in = new StreamTokenizer(br);
        out = new PrintWriter(writer);
    }

    void run() throws IOException {
        long beginTime = System.currentTimeMillis();
        init();
        solve();
        if(!oj){
            long endTime = System.currentTimeMillis();
            if (!oj) {
                System.out.println("Memory used = " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()));
                System.out.println("Running time = " + (endTime - beginTime));
            }
        }
        out.flush();
    }

    void solve() throws IOException{
        int n=nextInt(); double ct=nextInt(),dt=ct,t=0; A a[] = new A[n]; final double e=1E-10;
        for(int i=0; i<n; i++)a[i]=new A(nextInt(), nextInt(), nextInt());
        while(ct>0){
            dt=ct;
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++){
                    if((t=(a[i].x-a[j].x)/(a[j].v-a[i].v))<dt){
                        if(t<=e)continue; else dt=t;
                    }
                }
            }
            for(int i=0; i<n; i++){
                a[i].x+=a[i].v*dt;
            }
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++){
                    if(Math.abs(a[i].x-a[j].x)<e){
                        t=a[i].v;
                        a[i].v=((a[i].m-a[j].m)*a[i].v+2*a[j].m*a[j].v)/(a[i].m+a[j].m);
                        a[j].v=((a[j].m-a[i].m)*a[j].v+2*a[i].m*t)/(a[i].m+a[j].m);
                    }
                }
            }
            ct-=dt;
        }
        for(int i=0; i<n; i++)out.println((double)a[i].x);
    }
     
    int nextInt() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    long nextLong() throws IOException {
        in.nextToken();
        return (long) in.nval;
    }

    String nextString() throws IOException {
        in.nextToken();
        return in.sval;
    }

    double nextDouble() throws IOException {
        in.nextToken();
        return in.nval;
    }
}