// Arup Guha
// 12/31/2018
// Solution to 2018 December Gold Problem: Fine Dining

import java.util.*;
import java.io.*;

public class dining {
	
	final public static int OFFSET = 1000000001;
	public static int n;
	public static ArrayList[] orig;
	public static int[] yummy;
	
	public static void main(String[] args) throws Exception {
		
		// Read in the points, padding on the left and right ends.
		BufferedReader stdin = new BufferedReader(new FileReader("dining.in"));
		StringTokenizer tok = new StringTokenizer(stdin.readLine());
		n = Integer.parseInt(tok.nextToken());
		orig = new ArrayList[n];
		for (int i=0; i<n; i++) orig[i] = new ArrayList<edge>();
		int numE = Integer.parseInt(tok.nextToken());
		int numTreats = Integer.parseInt(tok.nextToken());
		yummy = new int[n];
		
		// Read in edges.
		for (int i=0; i<numE; i++) {
			tok = new StringTokenizer(stdin.readLine());
			int u = Integer.parseInt(tok.nextToken())-1;
			int v = Integer.parseInt(tok.nextToken())-1;
			int w = Integer.parseInt(tok.nextToken());
			orig[u].add(new edge(v,w));
			orig[v].add(new edge(u,w));
		}
		
		// Read in treats.
		for (int i=0; i<numTreats; i++) {
			tok = new StringTokenizer(stdin.readLine());
			int u = Integer.parseInt(tok.nextToken())-1;
			int val = Integer.parseInt(tok.nextToken());
			yummy[u] = val;
		}
		
		// Get shortest distances via Dijkstra's in the original graph, from vertex n-1.
		int[] shortest = dijkstras(orig, n-1);
		
		ArrayList[] treatG = makeTreatGraph();
		
		// Get shortest distance via Dijkstra's to the treat graph, #vertices = 2n.
		int[] treat = dijkstras(treatG, n-1);
		
		// Build answer by looking at each vertex.
		StringBuffer sb = new StringBuffer();
		for (int i=0; i<n-1; i++) {
			if (treat[n+i]-OFFSET <= treat[i])
				sb.append(1+"\n");
			else
				sb.append(0+"\n");
		}
		
		// Output to file.
		PrintWriter out = new PrintWriter(new FileWriter("dining.out"));
		out.print(sb);
		out.close();		
		stdin.close();
	}
	
	public static ArrayList[] makeTreatGraph() {
		
		ArrayList[] g = new ArrayList[2*n];
		for (int i=0; i<2*n; i++) g[i] = new ArrayList<edge>();
		
		// Add two levels of edges vertices 0 to n-1 are original vertices w/o treat.
		// vertices n to 2n-1 are mirrored vertices AFTER you've taken a treat.
		for (int i=0; i<n; i++) {
			for (int j=0; j<2*n; j+=n) {
				for (edge e: (ArrayList<edge>)orig[i]) {
					g[i+j].add(new edge(e.to+j, e.w));
					g[e.to+j].add(new edge(i+j, e.w));
				}
			}
		}
		
		// Now add edges for taking treats. Edge weight is -yummy, but we offset it
		// by OFFSET so there are no negative edge weights. We can get away with this
		// because all of these paths will have EXACTLY one edge with a treat taken.
		// So, I can recover my original shortest path accordingly.
		for (int i=0; i<n; i++) {
			if (yummy[i] > 0) {
				g[i].add(new edge(i+n,OFFSET-yummy[i]));
			}
		}
		
		return g;
	}
	
	public static int[] dijkstras(ArrayList[] g, int source) {
		
		// Set up distance array for Dijkstra's.
		int[] dist = new int[g.length];
		Arrays.fill(dist, Integer.MAX_VALUE);
		dist[source] = 0;
		boolean[] done = new boolean[dist.length];
		done[source] = true;
		
		// Set up the priority queue.
		PriorityQueue<edge> pq = new PriorityQueue<edge>();
		for (edge e: (ArrayList<edge>)g[source])
			pq.offer(e);
		
		// Go through each estimate.
		while (pq.size() > 0) {
			
			// Pull next estimate, skip if we already have best distance. 
			edge cur = pq.poll();
			if (done[cur.to]) continue;
			
			// Update best distance.
			dist[cur.to] = cur.w;
			done[cur.to] = true;
			
			// Now, update distances to edges leaving cur.to, if necessary.
			for (edge e: (ArrayList<edge>)g[cur.to])
				if (!done[e.to] && cur.w+e.w < dist[e.to])
					pq.offer(new edge(e.to, cur.w+e.w));
		}
		
		// Here are the distances.
		return dist;
	}
}

class edge implements Comparable<edge> {
	
	public int to;
	public int w;
	
	public edge(int v, int weight) {
		to = v;
		w = weight;
	}
	
	public int compareTo(edge other) {
		return this.w - other.w;
	}
}