import java.io.*;
import java.util.*;
public class dining {
static int V;
static int minDist(int dist[], boolean[] set1) {
int min = Integer.MAX_VALUE, min_index=-1; // Computers are too stupid to understand infinite
for (int v = 0; v < V; v++)
if (set1[v] == false && dist[v]
if (edgeDistance > 0 && ((shortestDistance + edgeDistance) < dists[vertexIndex])) {
parents[vertexIndex] = nearestVertex;
dists[vertexIndex] = shortestDistance +
edgeDistance;
}
//if(pastures.contains(new IPair(nearestVertex,vertexIndex))) {
//if(pastures.contains(nearestVertex) ) {
//System.out.println("Info: "+nearestVertex+" "+vertexIndex);
//System.out.println("Set "+(nearestVertex - 1) + " and "+(vertexIndex - 1));
//arr[nearestVertex] = 1;
//arr[vertexIndex] = 1;
/*
if(pasture[nearestVertex] > 0) {
for(int j = 0; j < N; j++) {
graph1[nearestVertex][j] = 0;
graph1[j][nearestVertex] = 0;
}
}
if(pasture[vertexIndex] > 0) {
for(int j = 0; j < N; j++) {
graph1[j][vertexIndex] = 0;
graph1[vertexIndex][j] = 0;
}
}
*/
//graph1[nearestVertex][vertexIndex] = 0;
//graph1[vertexIndex][nearestVertex] = 0;
//}
}
}
root = parents;
return dists;
}
public static void main(String[] args) throws IOException{
BufferedReader f = new BufferedReader(new FileReader("2.in"));
StringTokenizer st = new StringTokenizer(f.readLine());
int N = Integer.parseInt(st.nextToken());
int M = Integer.parseInt(st.nextToken());
int K = Integer.parseInt(st.nextToken());
int[][] matrix = new int[N+1][N+1];
arr = new int[N];
pasture = new int[N];
for(int i = 0; i < N; i++){
//Arrays.fill(matrix[i], Integer.MAX_VALUE);
}
for(int i = 0; i < M; i ++) {
st = new StringTokenizer(f.readLine());
int x = Integer.parseInt(st.nextToken()),y = Integer.parseInt(st.nextToken()),z = Integer.parseInt(st.nextToken());
matrix[x + 0 /*Remove offset*/][y + 0 /*Remove offset*/] = z;
matrix[y + 0 /*Remove offset*/][x + 0 /*Remove offset*/] = z;
}
//System.out.println(Arrays.deepToString(matrix).replaceAll("],*", "],\n"));
// Dijkstra Modification begins here
int[] out = dijkstra(matrix, N-1);
for(int i = 0; i < K; i++) {
st = new StringTokenizer(f.readLine());
int x = Integer.parseInt(st.nextToken());
int y = Integer.parseInt(st.nextToken());
//pasture[x-1] = y;
x = x + 0 /*Remove offset*/;
for(int j = 0; j < N; j++) {
if(matrix[j][x] != 0) {
//System.out.println("Override 1 "+j+" "+x+" "+y);
matrix[j][x] = out[x] - y;
}
if(matrix[x][j] != 0) {
//System.out.println("Override 2 "+x+" "+j+" "+y);
matrix[x][j] = out[x] - y;
}
}
//pastures.add(x);
//pastures.add(new IPair(x,y));
}
// End modification
System.out.println("Modifacation Complete");
//System.out.println(Arrays.deepToString(matrix).replaceAll("],*", "],\n"));
int[] out2 = dijkstra(matrix, N);
//System.out.println(Arrays.toString(root));
//System.out.println(Arrays.toString(out));
PrintWriter pw = new PrintWriter(new FileWriter("dining.out"));
for(int k = 0; k < arr.length -1; k ++) {
if(out[k] >= out2[k]) {
pw.println("1");
}else {
pw.println("0");
}
}
pw.close();
}
}
class IPair implements Comparable{
int x,y;
public IPair(int x,int y) {
this.x = x;
this.y = y;
}
public IPair() {
this.x = 0;
this.y = 0;
}
@Override
public int compareTo(IPair arg0) {
return this.x - arg0.x;
}
}