#include<bits/stdc++.h>
using namespace std;
int n,m,q;
vector<int> v[2005];
int a[100005],b[100005],c[100005];
int col[100005];
int vis[100005];
int main()
{
	scanf("%d%d%d",&n,&m,&q);
	for (int i=0;i<m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	int qq;
	scanf("%d",&qq);
	for (int i=0;i<qq;i++)
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
	for (int i=qq-1;i>=0;i--)
	{
		memset(vis,0,sizeof(vis));
		queue<int> q;
		q.push(a[i]);
		while(!q.empty())
		{
			int f=q.front();
			if (vis[f]>b[i])
				break;
			q.pop();
			for (int i=0;i<v[f].size();i++)
			{
				if (vis[v[f][i]]==0)
				{
					vis[v[f][i]]=vis[f]+1;
					q.push(v[f][i]);
				}
					
			}
		}
		for (int i=0;i<n;i++)
			if (vis[i]!=0 && col[i]==0)
				col[i]=c[i];
	}
	for (int i=0;i<n;i++)
		printf("%d\n",col[i]);
	return 0;
}