#include<bits/stdc++.h>
using namespace std;const int N=2e5+5;using ll=long long;int tid,T,n,m,q,d[N],c[N],w[N],g[N];ll ans[N],f[N];
vector<int>v[N];priority_queue<pair<ll,int>>pq;
void dfs(int u,int dis,ll val){if(dis<=g[u])return;
if(g[u]==-1)f[u]=val,pq.push({-val-c[u],u});g[u]=dis;for(auto i:v[u])dfs(i,dis-1,val);
}
void sol(){memset(f,0x3f,sizeof(f)),memset(g,-1,sizeof(g)),g[1]=f[1]=0,pq.push({-c[1],1});
while(!pq.empty()){int u=pq.top().second;pq.pop(),dfs(u,d[u],f[u]+c[u]);}
}
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
T=1;
while(T--){cin>>n>>m>>q;for(int i=1;i<=n;i++)cin>>d[i]>>c[i]>>w[i];
for(int x,y,i=1;i<=m;i++)cin>>x>>y,v[x].push_back(y),v[y].push_back(x);
sol();for(int i=1;i<=n;i++)ans[i]=f[i],c[i]+=(q-1)*w[i];
sol();for(int i=1;i<=n;i++)ans[i]=min(ans[i],f[i]);
for(int i=1;i<=n;i++)cout<<ans[i]<<'\n';
}
}