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 INP, AM, REACHEOF;
const int BUFSIZE = (1 << 12) + 17;
char BUF[BUFSIZE + 1], *inp = BUF;
struct Ball {
  double x, v, m;
} a[11];
int n;
const double EPS = 1e-6;
double collisionTime(Ball a, Ball b) {
  if (a.x > b.x) swap(a, b);
  if (a.v < 0 && b.v > 0) return 1e10;
  if (a.v >= 0 && b.v <= 0) {
    if (fabs(a.v) + fabs(b.v) < 1e-9) return 1e10;
    return (b.x - a.x) / (fabs(a.v) + fabs(b.v));
  } else {
    if (fabs(fabs(a.v) - fabs(b.v)) < 1e-9) return 1e10;
    if (a.v >= 0 && b.v >= 0 && a.v > b.v) return (b.x - a.x) / (a.v - b.v);
    if (a.v <= 0 && b.v <= 0 && fabs(a.v) < fabs(b.v))
      return (b.x - a.x) / (fabs(b.v) - fabs(a.v));
  }
  return 1e10;
}
double get() {
  double res = 1e10;
  for (int i = (1), _b = (n); i <= _b; i++)
    for (int j = (1), _b = (n); j <= _b; j++)
      if (fabs(a[i].x - a[j].x) > EPS) {
        res = min(res, collisionTime(a[i], a[j]));
      }
  return res;
}
void update(double t) {
  for (int i = (1), _b = (n); i <= _b; i++) a[i].x = a[i].x + a[i].v * t;
  for (int i = (1), _b = (n); i <= _b; i++)
    for (int j = (i + 1), _b = (n); j <= _b; j++) {
      if (fabs(a[i].x - a[j].x) < EPS) {
        double v1 = ((a[i].m - a[j].m) * a[i].v + 2 * a[j].m * a[j].v) /
                    (a[i].m + a[j].m);
        double v2 = ((a[j].m - a[i].m) * a[j].v + 2 * a[i].m * a[i].v) /
                    (a[i].m + a[j].m);
        a[i].v = v1;
        a[j].v = v2;
      }
    }
}
int main() {
  cout << fixed << setprecision(9);
  while (cin >> n) {
    double t;
    cin >> t;
    for (int i = (1), _b = (n); i <= _b; i++) cin >> a[i].x >> a[i].v >> a[i].m;
    double passed = 0;
    while (true) {
      double col = get();
      double mint = col + passed;
      if (mint > t) break;
      passed = mint;
      update(col);
    }
    if (passed < t) update(t - passed);
    for (int i = (1), _b = (n); i <= _b; i++) cout << a[i].x << endl;
  }
  return 0;
}