#include <bits/stdc++.h>
using namespace std;
template <typename T>
using vc = vector<T>;
using pii = pair<long long, long long>;
using pll = pair<long double, long double>;
void xmax(long long& a, long long b) { a = max(a, b); }
void xmin(long double& a, long double b) { a = min(a, b); }
void print(vc<long long>& a, string second) {
  cerr << "prinitng " << second << "\n";
  for (long long i = 0; i < a.size(); i++) {
    cerr << a[i] << " ";
  }
  cerr << endl;
}
vc<long double> w;
vc<long double> x;
vc<long double> v;
long double eps = 1e-12;
long long n;
long double t;
vc<pair<pll, pll> > a;
long double coll(long double x1, long double v1, long double x2,
                 long double v2) {
  if (v2 >= v1) return t + 7;
  long double dx = x2 - x1;
  long double b;
  b = v2 * dx / (v1 - v2);
  if (v2 != 0)
    return b / v2;
  else
    return (dx + b) / v1;
}
void do_collision(long long ind) {
  long double v1 = a[ind].first.second;
  long double v2 = a[ind + 1].first.second;
  assert(v2 < v1);
  long double dx = a[ind + 1].first.first - a[ind].first.first;
  long double b = v2 * dx / (v1 - v2);
  long double m1 = a[ind].second.first;
  long double m2 = a[ind + 1].second.first;
  a[ind].first.first = b + a[ind + 1].first.first;
  a[ind + 1].first.first += b;
  a[ind].first.second = ((m1 - m2) * v1 + 2 * m2 * v2) / (m1 + m2);
  a[ind + 1].first.second = ((m2 - m1) * v2 + 2 * m1 * v1) / (m1 + m2);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> t;
  vc<long double> w(n);
  vc<long double> x(n);
  vc<long double> v(n);
  a = vc<pair<pll, pll> >(n);
  for (long long i = 0; i < n; i++) {
    cin >> x[i] >> v[i] >> w[i];
    a[i] = {{x[i], v[i]}, {w[i], i}};
  }
  sort(a.begin(), a.end());
  long double cur_time = 0;
  while (true) {
    long double next = t - cur_time;
    vc<long double> times(n - 1);
    for (long long i = 0; i + 1 < n; i++) {
      times[i] = coll(a[i].first.first, a[i].first.second, a[i + 1].first.first,
                      a[i + 1].first.second);
      xmin(next, times[i]);
    }
    vc<long long> changed(n);
    for (long long i = 0; i + 1 < n; i++) {
      if (abs(times[i] - next) < eps) {
        changed[i] = 1;
        changed[i + 1] = 1;
        do_collision(i);
      }
    }
    for (long long i = 0; i < n; i++) {
      if (!changed[i]) a[i].first.first += next * a[i].first.second;
    }
    cur_time += next;
    if (abs(cur_time - t) < eps) break;
  }
  vc<long double> wo(n);
  for (long long i = 0; i < n; i++) {
    wo[a[i].second.second] = a[i].first.first;
  }
  for (long long i = 0; i < n; i++) {
    cout << setprecision(10) << wo[i] << "\n";
  }
  cerr << "end case \n\n";
}
