#include <bits/stdc++.h>
using namespace std;
template <typename Tp>
inline void outarr(Tp _array, const std::size_t _N, const char* _delim = " ") {
  Tp end = std::next(_array, _N);
  for (Tp current = _array; current != end; ++current) {
    std::cout << *current << _delim;
  }
  std::cout << '\n';
}
using ll = int64_t;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);
struct TBall {
  int M;
  double X;
  double V;
};
TBall arr[10];
int id[10];
double NewV(const TBall& a, const TBall& b) {
  return ((a.M - b.M) * a.V + 2.0 * b.M * b.V) / (a.M + b.M);
}
double TimeCollide(int i, int j) {
  if (abs(arr[i].X - arr[j].X) < 1e-6) {
    return 200;
  }
  if (arr[i].X > arr[j].X) {
    swap(i, j);
  }
  if (arr[i].V > 0 && arr[j].V < 0) {
    return (arr[j].X - arr[i].X) / (abs(arr[j].V) + abs(arr[i].V));
  }
  if (arr[i].V > 0 && arr[j].V > 0 && arr[i].V > arr[j].V ||
      arr[i].V < 0 && arr[j].V < 0 && arr[j].V < arr[i].V) {
    return (arr[j].X - arr[i].X) / abs(abs(arr[j].V) - abs(arr[i].V));
  }
  return 200;
}
vector<pii> pos;
char used[10];
double Step(int n, double t) {
  double mint = t;
  pos.clear();
  memset(used, 0, sizeof(used));
  sort(id, id + n, [](int i, int j) { return arr[i].X < arr[j].X; });
  for (int q = 1; q < n; ++q) {
    int i = id[q - 1];
    int j = id[q];
    double nt = TimeCollide(i, j);
    if (abs(nt - mint) < 1e-6) {
      pos.emplace_back(i, j);
    } else if (nt < mint) {
      mint = nt;
      pos.clear();
      pos.emplace_back(i, j);
    }
  }
  for (auto&& [i, j] : pos) {
    arr[i].X += arr[i].V * mint;
    arr[j].X += arr[j].V * mint;
    double vi = NewV(arr[i], arr[j]);
    double vj = NewV(arr[j], arr[i]);
    arr[i].V = vi;
    arr[j].V = vj;
    used[i] = used[j] = true;
  }
  for (int i = 0; i < (n); ++i) {
    if (!used[i]) {
      arr[i].X += arr[i].V * mint;
    }
  }
  return t - mint;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  double t;
  cin >> n >> t;
  for (int i = 0; i < (n); ++i) {
    cin >> arr[i].X >> arr[i].V >> arr[i].M;
    id[i] = i;
  }
  while (t > 0) {
    t = Step(n, t);
  }
  cout.setf(ios::fixed);
  cout.precision(7);
  for (int i = 0; i < (n); ++i) {
    cout << arr[i].X << "\n";
  }
  return 0;
}
