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;
double const INF = DBL_MAX / 2;
double const eps = 1e-8;
struct ball {
  double x, v, m;
  int id;
  ball(double x = 0, double v = 0, double m = 0, int id = 0)
      : x(x), v(v), m(m), id(id) {}
  double after(double t) { return x + t * v; }
  bool operator<(ball const &rhs) const { return x < rhs.x; }
} b[10];
double collide_time(ball &l, ball &r) {
  if (l.v <= 0 && r.v >= 0) return INF;
  if (l.v <= 0 && r.v <= 0 && l.v <= r.v) return INF;
  if (l.v >= 0 && r.v >= 0 && l.v <= r.v) return INF;
  return (r.x - l.x) / fabs(r.v - l.v);
}
void collide(ball &l, ball &r) {
  double lv = ((l.m - r.m) * l.v + 2 * r.m * r.v) / (l.m + r.m);
  double rv = ((r.m - l.m) * r.v + 2 * l.m * l.v) / (l.m + r.m);
  l.v = lv, r.v = rv;
}
int main() {
  int n, t;
  scanf("%d%d", &n, &t);
  for (int i = 0, x, v, m; i < n; ++i) {
    scanf("%d%d%d", &x, &v, &m);
    b[i] = ball(x, v, m, i);
  }
  sort(b, b + n);
  double ct[10]{};
  for (double rem = t; rem > 0;) {
    double mn = rem;
    for (int i = 0; i + 1 < n; ++i)
      mn = min(mn, ct[i] = collide_time(b[i], b[i + 1]));
    for (int i = 0; i < n; ++i) b[i].x = b[i].after(mn);
    rem -= mn;
    if (fabs(rem) < eps) break;
    for (int i = 0; i + 1 < n; ++i)
      if (fabs(mn - ct[i]) < eps) {
        collide(b[i], b[i + 1]);
      }
  }
  double p[10]{};
  for (int i = 0; i < n; ++i) p[b[i].id] = b[i].x;
  for (int i = 0; i < n; ++i) printf("%.16f\n", p[i]);
  return 0;
}