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;
const double eps = 0.000000001;
struct sh {
  double x, v, m;
  int k;
};
bool sortSH(const sh& lh, const sh& rh) { return lh.x < rh.x; }
bool sortSHind(const sh& lh, const sh& rh) { return lh.k < rh.k; }
double v1(sh& l, sh& r) {
  return ((l.m - r.m) * l.v + 2 * r.m * r.v) / (l.m + r.m);
}
double v2(sh& l, sh& r) {
  return ((r.m - l.m) * r.v + 2 * l.m * l.v) / (l.m + r.m);
}
int main() {
  int n, t;
  cin >> n >> t;
  vector<sh> ar(n + 2);
  ar[0].x = -500;
  ar[0].v = -500;
  ar[0].m = 5;
  ar[0].k = -100;
  ar[n + 1].x = 500;
  ar[n + 1].v = 500;
  ar[n + 1].m = 5;
  ar[n + 1].k = 500;
  for (int i = 1; i <= n; i++) {
    cin >> ar[i].x >> ar[i].v >> ar[i].m;
    ar[i].k = i;
  }
  sort(ar.begin(), ar.end(), sortSH);
  double cur = 0;
  bool ok = true;
  while (ok) {
    double mt = 10000000000.0;
    for (int i = 1; i <= n; i++) {
      double dv = ar[i - 1].v - ar[i].v;
      if (dv > 0) {
        mt = min(mt, abs(ar[i].x - ar[i - 1].x) / dv);
      }
    }
    if (cur + mt >= t) {
      mt = t - cur;
      ok = false;
    }
    for (int i = 1; i <= n + 1; i++) {
      double dv = ar[i - 1].v - ar[i].v;
      if (abs(abs(ar[i].x - ar[i - 1].x) / dv - mt) < eps) {
        sh arl = ar[i - 1], arr = ar[i];
        ar[i - 1].x += mt * ar[i - 1].v;
        ar[i].x += mt * ar[i].v;
        ar[i - 1].v = v1(arl, arr);
        ar[i].v = v2(arl, arr);
        i++;
      } else
        ar[i - 1].x += mt * ar[i - 1].v;
    }
    cur += mt;
  }
  sort(ar.begin(), ar.end(), sortSHind);
  for (int i = 1; i <= n; i++)
    cout << fixed << setprecision(7) << ar[i].x << endl;
  return 0;
}