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;
const double eps = 1e-9;
const int INF = 1 << 30;
const long long LINF = 1ll << 61;
const int BUFFER_SZ = 1 << 20;
const int MOD = 1000 * 1000 * 1000 + 9;
char BUFFER[BUFFER_SZ];
int gi() {
  int x;
  scanf("%d", &x);
  return x;
}
double gd() {
  double x;
  scanf("%lf", &x);
  return x;
}
long long gll() {
  long long x;
  scanf("%lld", &x);
  return x;
}
vector<int> gvi(int n) {
  vector<int> a;
  while (n-- > 0) a.push_back(gi());
  return a;
}
string gs() {
  scanf("%s", BUFFER);
  return string(BUFFER);
}
template <class T>
void print(vector<T> &x, string format) {
  format += "%c";
  for (int i = 0; i < x.size(); ++i)
    printf(format.c_str(), x[i], i + 1 == x.size() ? '\n' : ' ');
}
double X[12];
double M[12];
double V[12];
void move(int n, double t) {
  for (int i = 0; i < n; ++i) {
    X[i] += V[i] * t;
  }
  for (int a = 0; a < n; ++a) {
    for (int b = a + 1; b < n; ++b) {
      if (abs(X[a] - X[b]) < 1e-8) {
        double va = ((M[a] - M[b]) * V[a] + 2.0 * M[b] * V[b]) / (M[a] + M[b]);
        double vb = ((M[b] - M[a]) * V[b] + 2.0 * M[a] * V[a]) / (M[a] + M[b]);
        V[a] = va;
        V[b] = vb;
      }
    }
  }
}
double findNextEvent(int n) {
  double best = 1e100;
  for (int a = 0; a < n; ++a) {
    for (int b = a + 1; b < n; ++b) {
      double v = V[b] - V[a];
      if (abs(v) < 1e-8) continue;
      double d = X[b] - X[a];
      if (abs(d) < 1e-8) continue;
      if (d < 0.0 && v > 0.0) {
        best = min(best, abs(d) / abs(v));
      } else if (d > 0.0 && v < 0.0) {
        best = min(best, abs(d) / abs(v));
      }
    }
  }
  return best;
}
void solve() {
  int n = gi();
  double t = gd();
  for (int i = 0; i < n; ++i) {
    X[i] = gd();
    V[i] = gd();
    M[i] = gd();
  }
  while (abs(t) > 1e-8) {
    double tnext = findNextEvent(n);
    if (tnext > t) tnext = t;
    move(n, tnext);
    t -= tnext;
  }
  for (int i = 0; i < n; ++i) {
    printf("%.20lf\n", X[i]);
  }
}
int main() {
  solve();
  return 0;
}