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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
struct ball {
  float coord;
  int mass;
  float vel;
  short num;
};
bool sort_num(ball a, ball b) { return a.num < b.num; }
bool sort_coord(ball a, ball b) { return a.coord < b.coord; }
void collide(ball &a, ball &b) {
  float temp = a.vel;
  a.vel = ((a.mass - b.mass) * a.vel + 2 * b.vel * b.mass) / (b.mass + a.mass);
  b.vel = ((b.mass - a.mass) * b.vel + 2 * temp * a.mass) / (b.mass + a.mass);
}
void iter(vector<ball> &balls, int size, float &cur_time, int time) {
  float col_t = 9999.9;
  int col_c = -1;
  float temp;
  for (int i = 0; i < size - 1; i++) {
    temp = (balls[i + 1].coord - balls[i].coord) /
           (balls[i].vel - balls[i + 1].vel);
    if (temp > 0.0000001 && temp < col_t) {
      col_t = temp;
      col_c = i;
    }
  }
  if (cur_time + col_t > time || col_c == -1) {
    col_t = time - cur_time;
    for (int i = 0; i < size; i++) balls[i].coord += balls[i].vel * col_t;
    cur_time += col_t;
    return;
  }
  for (int i = 0; i < size; i++) {
    balls[i].coord += balls[i].vel * col_t;
  }
  for (int i = 0; i < size - 1; i++) {
    if (fabs(balls[i].coord - balls[i + 1].coord) < 0.0000001) {
      collide(balls[i], balls[i + 1]);
      i++;
    }
  }
  cur_time += col_t;
}
int main() {
  int n, t;
  float cur_t = 0.0;
  cin >> n >> t;
  vector<ball> balls(n);
  for (int i = 0; i < n; i++) {
    cin >> balls[i].coord >> balls[i].vel >> balls[i].mass;
    balls[i].num = i;
  }
  sort(balls.begin(), balls.end(), sort_coord);
  while (cur_t < t) {
    iter(balls, n, cur_t, t);
  }
  sort(balls.begin(), balls.end(), sort_num);
  for (int i = 0; i < n; i++) cout << balls[i].coord << endl;
  return 0;
}