#include <iostream>
#include <vector>
#include <fstream>
#include <iomanip>
#include<cmath>
using namespace std;
double pow1(double x,int n)
{
if (n == 1)
return x;
if (n == 0)
return 1;
double c = pow1(x, n / 2);
c *= c;
if (n % 2== 1)
c *= x;
return c;
}
vector<int> to, longTo;
vector<int> W;
int cnt = 1000;
vector<double> ans;
vector<double> longAns;
int main()
{
ifstream cin("input.txt");
ofstream cout("output.txt");
int n, m, k;
cin >> n >> m>> k;
to.resize(n);
double x;
cin >> x;
double longx = pow(x, cnt);
longTo.resize(n);
ans.resize(n);
longAns.resize(n);
W.resize(n, 1000000001);
for (int i = 0; i < m; ++i)
{
int a,b, w;
cin >> a >> b >> w;
--a;
--b;
if (W[a] > w)
{
W[a] = w;
to[a] = b;
}
if (W[b] > w)
{
W[b] = w;
to[b] = a;
}
}
for (int i = 0; i < n; ++i)
{
int a = i;
// cout << a + 1<< " " << to[a] + 1 << endl;
for (int i1 = 0; i1 < cnt ; ++i1)
{
a = to[a];
}
longTo[i] = a;
}
for (int i = 0; i < k; ++i)
{
int v, t;
double p;
cin >> v >> p >> t;
int v1 = v;
--v;
for (int i1 = 0; i1 < t / cnt; ++i1)
{
longAns[v] += p;
p *= longx;
v = longTo[v];
}
for (int i1 = 0; i1 < t % cnt; ++i1)
{
ans[v] += p;
// cout << v << " " << " ";
v = to[v];
p *= x;
if (p < 1e-15)
break;
}//cout << endl;
}
for (int i = 0; i < n; ++i)
{
int v= i;
double p = longAns[i];
//cout << p << endl;
for (int i1 = 0; i1 < cnt; ++i1)
{
ans[v] += p;
p *= x;
v = to[v];
}
cout << fixed << setprecision(10) << ans[i] << endl;
}
return 0;
}