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;
long long vs[300000], b[300000], ok[300000];
vector<pair<int, int> > v;
class obj {
 public:
  double x, v, m;
  void input() { cin >> x >> v >> m; }
};
int main() {
  ios_base::sync_with_stdio(false);
  double n, m, k = 1, t, l = 0, th, h = 0, tt = 0, v1, v2;
  int i, j, ix1 = 0, ix2 = 0;
  obj a[30];
  cin >> n >> t;
  for (i = 1; i <= n; i++) a[i].input();
  while (1) {
    l = INT_MAX;
    for (i = 1; i < n; i++)
      for (j = i + 1; j <= n; j++)
        if (a[i].v != a[j].v) {
          h = (a[j].x - a[i].x) / (a[i].v - a[j].v);
          if (h < l && h > 0) l = h;
        }
    for (i = 1; i < n; i++)
      for (j = i + 1; j <= n; j++)
        if (a[i].v != a[j].v) {
          h = (a[j].x - a[i].x) / (a[i].v - a[j].v);
          if (abs(h - l) < 1e-9) v.push_back({i, j});
        }
    if (tt + l >= t) {
      l = t - tt;
      break;
    }
    for (i = 1; i <= n; i++) {
      a[i].x = a[i].x + a[i].v * l;
    }
    for (k = 0; k < v.size(); k++) {
      i = v[k].first;
      j = v[k].second;
      v1 = ((a[i].m - a[j].m) * a[i].v + 2 * a[j].m * a[j].v) /
           (a[i].m + a[j].m);
      v2 = a[i].v + v1 - a[j].v;
      a[i].v = v1;
      a[j].v = v2;
    }
    v.clear();
    tt += l;
  }
  for (i = 1; i <= n; i++) {
    a[i].x = a[i].x + a[i].v * l;
  }
  for (i = 1; i <= n; i++) cout << fixed << setprecision(12) << a[i].x << endl;
  return 0;
}