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 MOD = 1000000007;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline long long toll(string s) {
  long long v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
double getV(double m1, double m2, double v1, double v2) {
  return (((m1 - m2) * v1) + 2 * m2 * v2) / (m1 + m2);
}
double getTimeOfIntersect(double v1, double v2, double dist, bool &can) {
  if (abs(v1 - v2) < 1e-9) {
    can = false;
    return 1e16;
  }
  double time = dist / (v2 - v1);
  if (time < 1e-9) {
    can = false;
    return 1e16;
  }
  can = true;
  return time;
}
struct ball {
  double x, m, v;
};
bool done[11];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  vector<ball> v;
  int n;
  cin >> n;
  int t;
  cin >> t;
  for (int i = 0; i < n; i++) {
    ball b;
    cin >> b.x >> b.v >> b.m;
    v.push_back(b);
  }
  double elapsedTime = 0;
  while (1) {
    memset(done, 0, sizeof(done));
    double smallestCollide = 1e16;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        double time = 0;
        bool can = false;
        time = getTimeOfIntersect(v[i].v, v[j].v, v[i].x - v[j].x, can);
        if (can) {
          smallestCollide = min(time, smallestCollide);
        }
      }
    }
    if (elapsedTime + smallestCollide > t + 1e-9) {
      smallestCollide = t - elapsedTime;
      for (int i = 0; i < n; i++) {
        v[i].x += +v[i].v * smallestCollide;
      }
      break;
    } else {
      elapsedTime += smallestCollide;
      for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
          bool can;
          if (abs(smallestCollide -
                  getTimeOfIntersect(v[i].v, v[j].v, v[i].x - v[j].x, can)) <
              1e-9) {
            done[i] = done[j] = 1;
            v[i].x += v[i].v * smallestCollide;
            v[j].x += v[j].v * smallestCollide;
            double temp = v[i].v;
            v[i].v = getV(v[i].m, v[j].m, v[i].v, v[j].v);
            v[j].v = getV(v[j].m, v[i].m, v[j].v, temp);
          }
        }
      }
      for (int i = 0; i < n; i++) {
        if (!done[i]) {
          v[i].x += smallestCollide * v[i].v;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << setprecision(12) << v[i].x << endl;
  }
  return 0;
}