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;
int const MAXN = 1000;
double const eps = 1e-8;
int n;
double t, ans[MAXN];
struct elem {
  double x, v, m;
  int num;
} s[MAXN];
void change_all(double add_time) {
  for (int i = 0; i < n; i++) s[i].x += s[i].v * add_time;
}
int r_eq(double a, double b) { return fabs(a - b) <= eps; }
int r_le(double a, double b) { return b - a >= eps || fabs(a - b) <= eps; }
int r_me(double a, double b) { return a - b >= eps || fabs(a - b) <= eps; }
int r_m(double a, double b) { return a - b >= eps; }
int stolk(double v1, double v2) { return r_m(v1, v2); }
bool operator<(const elem &a, const elem &b) { return a.x < b.x; }
int main() {
  cin >> n >> t;
  for (int i = 0; i < n; i++) {
    cin >> s[i].x >> s[i].v >> s[i].m;
    s[i].num = i;
  }
  double cur_time = 0;
  sort(s, s + n);
  while (1) {
    double mn = 1e100;
    for (int i = 0; i < n - 1; i++) {
      int j = i + 1;
      if (stolk(s[i].v, s[j].v)) {
        double dst = fabs(s[i].x - s[j].x);
        double tm;
        tm = dst / (s[i].v - s[j].v);
        tm = fabs(tm);
        if (tm < mn) mn = tm;
      }
    }
    if (cur_time + mn > t) break;
    change_all(mn);
    cur_time += mn;
    for (int i = 0; i < n - 1; i++)
      if (r_eq(s[i].x, s[i + 1].x)) {
        int a = i;
        int b = i + 1;
        double v1 = s[a].v;
        double m1 = s[a].m;
        double v2 = s[b].v;
        double m2 = s[b].m;
        double new_v1 = ((m1 - m2) * v1 + 2 * m2 * v2) / (m1 + m2);
        double new_v2 = ((m2 - m1) * v2 + 2 * m1 * v1) / (m1 + m2);
        s[a].v = new_v1;
        s[b].v = new_v2;
      }
  }
  change_all(t - cur_time);
  for (int i = 0; i < n; i++) ans[s[i].num] = s[i].x;
  for (int i = 0; i < n; i++) printf("%.8lf\n", ans[i]);
  return 0;
}