Problem: Dima took up the biology of bacteria, as a result of his experiments, he invented k types of bacteria. Overall, there are n bacteria at his laboratory right now, and the number of bacteria of type i equals ci. For convenience, we will assume that all the bacteria are numbered from 1 to n. The bacteria of type ci are numbered from <image> to <image>.

With the help of special equipment Dima can move energy from some bacteria into some other one. Of course, the use of such equipment is not free. Dima knows m ways to move energy from some bacteria to another one. The way with number i can be described with integers ui, vi and xi mean that this way allows moving energy from bacteria with number ui to bacteria with number vi or vice versa for xi dollars.

Dima's Chef (Inna) calls the type-distribution correct if there is a way (may be non-direct) to move energy from any bacteria of the particular type to any other bacteria of the same type (between any two bacteria of the same type) for zero cost.

As for correct type-distribution the cost of moving the energy depends only on the types of bacteria help Inna to determine is the type-distribution correct? If it is, print the matrix d with size k × k. Cell d[i][j] of this matrix must be equal to the minimal possible cost of energy-moving from bacteria with type i to bacteria with type j.

Input

The first line contains three integers n, m, k (1 ≤ n ≤ 105; 0 ≤ m ≤ 105; 1 ≤ k ≤ 500). The next line contains k integers c1, c2, ..., ck (1 ≤ ci ≤ n). Each of the next m lines contains three integers ui, vi, xi (1 ≤ ui, vi ≤ 105; 0 ≤ xi ≤ 104). It is guaranteed that <image>.

Output

If Dima's type-distribution is correct, print string «Yes», and then k lines: in the i-th line print integers d[i][1], d[i][2], ..., d[i][k] (d[i][i] = 0). If there is no way to move energy from bacteria i to bacteria j appropriate d[i][j] must equal to -1. If the type-distribution isn't correct print «No».

Examples

Input

4 4 2
1 3
2 3 0
3 4 0
2 4 1
2 1 2


Output

Yes
0 2
2 0


Input

3 1 2
2 1
1 2 0


Output

Yes
0 -1
-1 0


Input

3 2 2
2 1
1 2 0
2 3 1


Output

Yes
0 1
1 0


Input

3 0 2
1 2


Output

No

Solution (in JAVA):

Solution:
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.prefs.BackingStoreException;

public class Solver {

	public static void main(String[] Args) throws NumberFormatException,
			IOException {
		new Solver().Run();
	}

	PrintWriter pw;
	StringTokenizer Stok;
	BufferedReader br;

	public String nextToken() throws IOException {
		while (Stok == null || !Stok.hasMoreTokens()) {
			Stok = new StringTokenizer(br.readLine());
		}
		return Stok.nextToken();
	}

	public int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}

	public double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(nextToken());
	}

	public long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(nextToken());
	}

	int kolTypes;
	int kolBact;
	int kolEdges;
	
	class TEdge{
		int weight;
		int dir;
		
		public TEdge(int aWeight, int aDir){
			weight=aWeight;
			dir=aDir;
		}
	}
	
	List<List<TEdge>> bactGraph;
	int[][] typeGraph;
	int[] typeOfBact;
	int[] kolType;
	int[] numOfGroup;
	final int MaxValue=10000000;
	
	public void goBFS(int start, int curGroup){
		Queue<Integer> que=new LinkedList<Integer>();
		que.add(start);
		numOfGroup[start]=curGroup;
		int curVert;
		while (!que.isEmpty()){
			curVert=que.poll();
			for (TEdge edge : bactGraph.get(curVert)) {
				if (numOfGroup[edge.dir]!=curGroup && edge.weight==0){
					que.add(edge.dir);
					numOfGroup[edge.dir]=curGroup;
				}
			}
		}
	}
	
	public boolean checkTypeCorrect(){
		for (int i=1; i<kolBact; i++){
			if (typeOfBact[i]==typeOfBact[i-1] && numOfGroup[i]!=numOfGroup[i-1])
				return false;
		}
		return true;
	}
	
	public void Run() throws NumberFormatException, IOException {
		//br = new BufferedReader(new FileReader("input.txt")); pw = new PrintWriter("output.txt");
		br=new BufferedReader(new InputStreamReader(System.in));  pw=new PrintWriter(new OutputStreamWriter(System.out));
		
		kolBact=nextInt();
		kolEdges=nextInt();
		kolTypes=nextInt();
		kolType=new int[kolTypes];
		for (int i=0; i<kolTypes; i++){
			kolType[i]=nextInt();
		}
		typeOfBact=new int[kolBact];
		int j=0;
		for (int i=0; i<kolTypes; i++){
			for (int k=0; k<kolType[i]; k++){
				typeOfBact[j]=i;
				j++;
			}
		}
		
		typeGraph=new int[kolTypes][kolTypes];
		for (int i=0; i<kolTypes; i++){
			for (j=i+1; j<kolTypes; j++){
				typeGraph[i][j]=MaxValue;
				typeGraph[j][i]=MaxValue;
			}
		}
		
		bactGraph=new ArrayList<List<TEdge>>();
		for (int i=0; i<kolBact; i++){
			bactGraph.add(new LinkedList<Solver.TEdge>());
		}
		
		for (int i=0; i<kolEdges; i++){
			int v1=nextInt()-1;
			int v2=nextInt()-1;
			int weight=nextInt();
			typeGraph[typeOfBact[v1]][typeOfBact[v2]]=Math.min(weight, typeGraph[typeOfBact[v1]][typeOfBact[v2]]);
			typeGraph[typeOfBact[v2]][typeOfBact[v1]]=typeGraph[typeOfBact[v1]][typeOfBact[v2]];
			TEdge forw=new TEdge(weight, v2);
			bactGraph.get(v1).add(forw);
			TEdge backw=new TEdge(weight, v1);
			bactGraph.get(v2).add(backw);
		}
		
		numOfGroup=new int[kolBact];
		for (int i=0; i<kolBact; i++){
			numOfGroup[i]=-1;
		}
		
		int curGroup=0;
		for (int i=0; i<kolBact; i++){
			if (numOfGroup[i]<0){
				curGroup++;
				goBFS(i, curGroup);
			}
		}
		
		if (!checkTypeCorrect()){
			pw.println("No");
			pw.flush();
			pw.close();
			return;
		}
		
		for (int keyVert=0; keyVert<kolTypes; keyVert++){
			for (int i=0; i<kolTypes; i++){
				for (j=i+1; j<kolTypes; j++){
					typeGraph[i][j]=Math.min(typeGraph[i][j], typeGraph[i][keyVert]+typeGraph[keyVert][j]);
					typeGraph[j][i]=typeGraph[i][j];
				}
			}
		}
		
		pw.println("Yes");
		for (int i=0; i<kolTypes; i++){
			for (j=0; j<kolTypes; j++){
				if (typeGraph[i][j]<MaxValue)
					pw.print(typeGraph[i][j]);
				else
					pw.print(-1);
				pw.print(' ');
			}
			pw.println();
		}
		
		pw.flush();
		pw.close();
	}

}