// Arup Guha
// 7/3/2020
// Solution to 2020 USACO February Gold Problem: Timeline

import java.util.*;
import java.io.*;

public class timeline {
	
	// Store earliest times.
	public static int n;
	public static int[] times;
	
	// Store graph for top sort.
	public static ArrayList[] g;
	public static int[] indeg;
	
	public static void main(String[] args) throws Exception {
		
		// Read in the array.
		BufferedReader stdin = new BufferedReader(new FileReader("timeline.in"));
		StringTokenizer tok = new StringTokenizer(stdin.readLine());
		
		// Read in first line, set up graph.
		n = Integer.parseInt(tok.nextToken());
		int m = Integer.parseInt(tok.nextToken());
		int numMem = Integer.parseInt(tok.nextToken());
		g = new ArrayList[n];
		for (int i=0; i<n; i++) g[i] = new ArrayList<edge>();
		indeg = new int[n];
		
		// Read min times.
		times = new int[n];
		tok = new StringTokenizer(stdin.readLine());
		for (int i=0; i<n; i++)
			times[i] = Integer.parseInt(tok.nextToken());
		
		// Read through the edges of the graph (memories)
		for (int i=0; i<numMem; i++) {
			tok = new StringTokenizer(stdin.readLine());
			int u = Integer.parseInt(tok.nextToken()) - 1;
			int v = Integer.parseInt(tok.nextToken()) - 1;
			int t = Integer.parseInt(tok.nextToken());
			g[u].add(new edge(v, t));
			indeg[v]++;
		}
		
		// Will store vertices with in degree 0.
		LinkedList<Integer> q = new LinkedList<Integer>();
		for (int i=0; i<n; i++)
			if (indeg[i] == 0)
				q.offer(i);
			
		// We know that a valid topsort exists, so run it.
		for (int i=0; i<n; i++) {
			
			// Get next.
			int next = q.pollFirst();
			
			// Process each edge from this vertex.
			for (edge e: (ArrayList<edge>)g[next]) {
				
				// Update the earliest time to this vertex.
				times[e.to] = Math.max(times[e.to], times[next]+e.w);
				
				// sub 1 from the edges coming into here.
				indeg[e.to]--;
				
				// No more incoming edges, safe to add to queue.
				if (indeg[e.to] == 0)
					q.offer(e.to);
			}
		}
		
		// Build answer.
		StringBuffer sb = new StringBuffer();
		for (int i=0; i<n; i++)
			sb.append(times[i]+"\n");

		// Output to file.
		PrintWriter out = new PrintWriter(new FileWriter("timeline.out"));
		out.print(sb);
		out.close();		
		stdin.close();		
	}
	
}

class edge {
	
	public int to;
	public int w;
	
	public edge(int v2, int time) {
		to = v2;
		w = time;
	}
}