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.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class DimaAndBacteria 
{
	static class Sorter implements Comparator<Integer>
	{

		@Override
		public int compare(Integer arg0, Integer arg1) 
		{
			return matrix[mode][arg0] - matrix[mode][arg1];
		}
	}
	
	static int mode;
	static int n; //number of bacteria/vertices
	static int m; //number of edges
	static int k; //number of alleged types
	static int[] al; //number of alleged numbers of bacteria of each type
	
	static int[] parent;
	static int[] edgea;
	static int[] edgeb;
	static int[] edgec;
	static int[][] matrix;
	
	
	static int root(int i)
	{
		if(parent[i] != i)
		{
			int r = root(parent[i]);
			parent[i] = r;
			return r;
		}
		else
		{
			return i;
		}
	}
	
	static void merge(int a, int b)
	{
//		System.out.println("Merging " + a + " " + b);
		parent[root(b)] = root(a);
	}
	
	static int groupof(int index)
	{
		int rem = index;
		for(int g = 0; g < k; g++)
		{
			if(rem < al[g])
			{
				return g;
			}
			else
			{
				rem -= al[g];
			}
		}
		return k-1;
	}
	
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		boolean debug = true;
		
		n = sc.nextInt();
		m = sc.nextInt();
		k = sc.nextInt();
		al = new int[k];
		parent = new int[n];
		edgea = new int[m];
		edgeb = new int[m];
		edgec = new int[m];
		
		for(int i = 0; i < n; i++)
		{
			parent[i] = i;
		}
		
		for(int i = 0; i < k; i++)
		{
			al[i] = sc.nextInt();
		}
		
		for(int i = 0; i < m; i++)
		{
			int e1 = sc.nextInt()-1;
			int e2 = sc.nextInt()-1;
			int cost = sc.nextInt();
			
			edgea[i] = e1;
			edgeb[i] = e2;
			edgec[i] = cost;
			if(cost == 0)
			{
				merge(e1, e2);
			}
		}
		

		{
			int i = 0;
			int until = 0;
			for(int g = 0; g < k; g++)
			{
//				System.out.println("Group " + g);
				until += al[g];
				boolean first = true;
				while(i < until)
				{
					if(!first)
					{
//						System.out.println("Checking " + i + " " + (i-1) + " " + root(i) + " " + root(i-1));
						if(root(i) != root(i-1))
						{
							System.out.println("No");
							return;
						}
						//see if same root with previous.
					}
					
					first = false;
					
					i++;
				}
			}
		}

		
//		System.out.println(Arrays.toString(grouplist));
//		System.out.println(group);
		
//		Arrays.sort(al);
//		Arrays.sort(grouplist);

		System.out.println("Yes");
		
		matrix = new int[k][k];
		for(int i = 0; i < k; i++)
		{
			for(int j = 0; j < k; j++)
			{
				matrix[i][j] = 1000001;
			}
		}
		
		
		for(int i = 0; i < m; i++)
		{
			//reiterate through edge input
			int e1 = edgea[i];
			int e2 = edgeb[i];
			int g1 = groupof(e1);
			int g2 = groupof(e2);
			if(g1 != g2)
			{
				if(g2 < g1)
				{
					int temp = g1;
					g1 = g2;
					g2 = temp;
				}
				if(matrix[g1][g2] != matrix[g2][g1])System.out.println("ERROR! ERROR!");
				matrix[g1][g2] = Math.min(matrix[g1][g2], edgec[i]);
				matrix[g2][g1] = matrix[g1][g2];
			}
		}
		
//		int[][] matrix2 = new int[k][k];
		for(int i = 0; i < k; i++)
		{
			matrix[i][i] = 0;
			boolean[] visited = new boolean[k];
//			Stack<Integer> queue = new Stack<Integer>();
			mode = i;
			Sorter C = new Sorter();
			PriorityQueue<Integer> queue = new PriorityQueue<Integer>(C);
			
			queue.add(i);
			visited[i] = true;
			while(!queue.isEmpty())
			{
				int pos = queue.poll();
				//traverse
//				System.out.println("[" + i + "] Traversing " + pos);
				for(int j = 0; j < k; j++)
				{
					if(pos != j && matrix[pos][j] < 1000001)
					{
//						System.out.println("Can visit from " + pos + "(" + matrix[i][pos] + ") to " + j);
						if(matrix[i][j] != matrix[j][i])System.out.println("ERROR! ERROR!");
//						if(matrix[i][j] == 0) {matrix[i][j] = 1000001;}
						matrix[i][j] = Math.min(matrix[i][j], matrix[i][pos] + matrix[pos][j]);
						matrix[j][i] = matrix[i][j];
						
						if(!visited[j])
						{
							queue.add(j);
							visited[j] = true;
						}
					}
				}
			}
		}
		
		StringBuilder sb = new StringBuilder();
		for(int r = 0; r < k; r++)
		{
			for(int x = 0; x < k; x++)
			{
				if(r != x && matrix[r][x] == 1000001)matrix[r][x] = -1;
				if(r == x) {matrix[r][x] = 0;}
//				System.out.print(matrix[r][x]);
//				if(x < k-1)System.out.print(" ");
				sb.append(matrix[r][x]);
				if(x < k-1)sb.append(" ");
			}
//			System.out.print("\n");
			sb.append("\n");
		}
		
		System.out.print(sb);
		
//		System.out.println("GROUPS: " + group);
	}
}