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.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

public class ProblemE {
	
	static class Ball {
		double x;
		double v;
		double m;
		Ball(String[] data) {
			x = Double.valueOf(data[0]);
			v = Double.valueOf(data[1]);
			m = Double.valueOf(data[2]);
		}
		
		double collideTime(Ball with) {
			Ball a = this;
			Ball b = with;
			if (a.x > b.x) {
				Ball tmp = a;
				a = b;
				b = tmp;
			}
			double dist = b.x - a.x;
			double bav = a.v - b.v;
			if (bav <= 0) {
				return Double.MAX_VALUE;
			}
			return dist / bav;
		}

		public void collide(Ball with) {
			double v1 = ((m - with.m) * v + 2 * with.m * with.v) / (m + with.m);
			double v2 = ((with.m - m) * with.v + 2 * m * v) / (m + with.m);
			v = v1;
			with.v = v2;
		}

		public void proceed(double leftTime) {
			x += v * leftTime;
		}

	}
	
	public static void main(String[] args) throws IOException {
		BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);

		String[] nt = s.readLine().split(" ");
		int n = Integer.valueOf(nt[0]);
		int t = Integer.valueOf(nt[1]);
		Ball[] b = new Ball[n];
		for (int i = 0 ; i < n ; i++) {
			b[i] = new Ball(s.readLine().split(" "));
		}
		
		double now = 0;
		int prv = -1;
		int prv2 = -1;
		while (now < t) {
			double timeToCollision = t * 100;
			int x = -1;
			int y = -1;
			for (int i = 0 ; i < n ; i++) {
				for (int j = i+1 ; j < n ; j++) {
					if (prv == i && prv2 == j) {
						continue;
					}
					double willCollideAt = b[i].collideTime(b[j]);
					if (timeToCollision > willCollideAt) {
						timeToCollision = willCollideAt;
						x = i;
						y = j;
					}
				}
			}
			if (now + timeToCollision >= t) {
				double leftTime = t - now;
				for (int i = 0 ; i < n ; i++) {
					b[i].proceed(leftTime);
				}
				break;
			} else {
				prv = x;
				prv2 = y;
				for (int i = 0 ; i < n ; i++) {
					b[i].proceed(timeToCollision);
				}
				b[x].collide(b[y]);
				now += timeToCollision;
			}
		}
		
		for (int i = 0 ; i < n ; i++) {
			out.println(b[i].x);
		}
		out.flush();
	}

	public static void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}
}