#include <iostream>
#include<cstring>
using namespace std;
const int N=405;
typedef long long LL;
const LL mod=0x3f3f3f3f3f3f3f3f;
LL dist[N][N],n,m,q;
void Floyd()
{
for(int k=1;k<=n;k++)
{
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
}
}
}
}
int main()
{
cin>>n>>m>>q;
memset(dist,0x3f,sizeof dist);
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
if(i==j) dist[i][j]=0;
while(m--)
{
LL u,v,w;
cin>>u>>v>>w;
dist[u][v]=dist