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;
#pragma comment(linker, "/STACK:102400000,102400000")
template <class T>
T _max(T x, T y) {
  return x > y ? x : y;
}
template <class T>
T _min(T x, T y) {
  return x < y ? x : y;
}
template <class T>
T _abs(T x) {
  return (x < 0) ? -x : x;
}
template <class T>
T _mod(T x, T y) {
  return (x > 0) ? x % y : ((x % y) + y) % y;
}
template <class T>
void _swap(T& x, T& y) {
  T t = x;
  x = y;
  y = t;
}
template <class T>
void getmax(T& x, T y) {
  x = (y > x) ? y : x;
}
template <class T>
void getmin(T& x, T y) {
  x = (x < 0 || y < x) ? y : x;
}
int TS, cas = 1;
const int M = 10 + 5;
int n;
double t;
struct ball {
  double x, v, m;
  ball() {}
  ball(double _x, double _v, double _m) { x = _x, v = _v, m = _m; }
  void read() { scanf("%lf%lf%lf", &x, &v, &m); }
} p[M];
bool vis[M];
void collisions(int i, int j) {
  double v1 =
      ((p[i].m - p[j].m) * p[i].v + 2.0 * p[j].m * p[j].v) / (p[i].m + p[j].m);
  double v2 =
      ((p[j].m - p[i].m) * p[j].v + 2.0 * p[i].m * p[i].v) / (p[i].m + p[j].m);
  p[i].v = v1, p[j].v = v2;
}
void run() {
  int i, j;
  for (i = 1; i <= n; i++) p[i].read();
  double now = 0;
  memset(vis, 0, sizeof(vis));
  while (t > now && fabs(now - t) > (1e-8)) {
    double mint = 10000.0, tmp;
    int b1 = -1, b2 = -1;
    for (i = 1; i <= n; i++) {
      for (j = i + 1; j <= n; j++) {
        if (fabs(p[i].v - p[j].v) <= (1e-8)) continue;
        tmp = (p[i].x - p[j].x) / (p[j].v - p[i].v);
        if (tmp < 0) continue;
        if (fabs(tmp) <= (1e-8)) {
          if (!vis[i]) collisions(i, j);
          continue;
        }
        if (mint > tmp) mint = tmp, b1 = i, b2 = j;
      }
    }
    if (b1 == -1 || now + mint > t) break;
    now += mint;
    memset(vis, 0, sizeof(vis));
    for (i = 1; i <= n; i++)
      if (!vis[i]) {
        for (j = i + 1; j <= n; j++)
          if (!vis[j]) {
            if (fabs(p[i].v - p[j].v) <= (1e-8)) continue;
            tmp = (p[i].x - p[j].x) / (p[j].v - p[i].v);
            if (tmp < 0) continue;
            if (fabs(tmp - mint) <= (1e-8)) {
              vis[i] = vis[j] = 1;
              p[i].x += p[i].v * mint, p[j].x += p[j].v * mint;
              collisions(i, j);
            }
          }
      }
    for (i = 1; i <= n; i++)
      if (!vis[i]) p[i].x += p[i].v * mint;
  }
  for (i = 1; i <= n; i++) printf("%.9lf\n", p[i].x + p[i].v * (t - now));
}
void preSof() {}
int main() {
  preSof();
  while ((~scanf("%d%lf", &n, &t))) run();
  return 0;
}