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;
template <typename T>
inline T SQR(T a) {
  return a * a;
}
template <typename T>
struct point {
  T x, y;
  point(const T& _x, const T& _y) : x(_x), y(_y) {}
  point() : x(0), y(0) {}
  bool operator<(const T& r) { return x == r.x ? y < r.y : x < r.x; }
};
const double INF = numeric_limits<int>::max() / 1000;
const double eps = 1e-10;
const double PI = 2 * asin(1.0);
struct ball {
  double x, v, m, lc;
};
double _time = 0;
double _ctime = 0;
void process_next(vector<ball>& v) {
  int sz = v.size();
  int mi = -1, mj = -1;
  double mt = INF;
  for (int i = 0; i < (int)(sz); ++i) {
    for (int j = i + 1; j < (int)(sz); ++j) {
      double tt = INF;
      if (v[i].v - v[j].v != 0) {
        tt = (v[j].x - v[i].x) / (v[i].v - v[j].v);
        if (tt < 0) {
          tt = INF;
        }
      }
      if (abs(tt) < eps && abs(v[i].lc - _ctime) < eps &&
          abs(v[j].lc - _ctime) < eps)
        continue;
      if (mt > tt) {
        mt = tt;
        mi = i;
        mj = j;
      }
    }
  }
  double ntime = min(_time - _ctime, mt);
  for (int i = 0; i < (int)(sz); ++i) {
    v[i].x += v[i].v * ntime;
  }
  if (mi != -1) {
    double v1 = v[mi].v;
    double v2 = v[mj].v;
    v[mi].v =
        ((v[mi].m - v[mj].m) * v1 + 2 * v[mj].m * v2) / (v[mi].m + v[mj].m);
    v[mj].v =
        ((v[mj].m - v[mi].m) * v2 + 2 * v[mi].m * v1) / (v[mi].m + v[mj].m);
    v[mi].lc = _ctime + ntime;
    v[mj].lc = _ctime + ntime;
  }
  _ctime += ntime;
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n >> _time;
  vector<ball> v(n);
  for (int i = 0; i < (int)(n); ++i) {
    cin >> v[i].x >> v[i].v >> v[i].m;
    v[i].lc = -1;
  }
  while (_ctime < _time) {
    process_next(v);
  }
  for (int i = 0; i < (int)(n); ++i) {
    cout << setprecision(6) << fixed << v[i].x << '\n';
  }
  return 0;
}