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.*;
import java.util.*;
public class CF400D {
	public static void main(String[] args) throws IOException {
		in.init(System.in);
		PrintWriter out = new PrintWriter(System.out);
		n = in.nextInt();		
		int m = in.nextInt();
		k = in.nextInt();
		c = new int[k];
		csum = new int[k];
		for(int i = 0; i < k; i ++)
			c[i] = in.nextInt();
		csum[0] = c[0]-1;
		for(int i = 1; i < k; i ++)
			csum[i] = csum[i-1]+c[i];
		adj = new ArrayList[n];
		edges = new ArrayList[n];
		for(int i = 0; i < n; i ++)
		{
			adj[i] = new ArrayList<Integer>();
			edges[i] = new ArrayList<Edge>();
		}
		for(int i = 0; i < m; i ++)
		{
			int a = in.nextInt()-1;
			int b = in.nextInt()-1;
			int x = in.nextInt();
			edges[a].add(new Edge(b, x));
			edges[b].add(new Edge(a, x));
			if(x!=0)
				continue;
			adj[a].add(b);
			adj[b].add(a);
		}	
		scc();
		boolean ans = true;
		
		for(int i = 0; i < k; i ++)
		{
			int first = 0;
			if(i>0)
				first = csum[i-1]+1;
			int last = csum[i];
			int cc = id[first];
			for(int j = first+1; j <= last; j ++)
			{
				if(id[j]!=cc)
				{
					ans = false;
					break;
				}
			}
			if(!ans)
				break;
		}
		
		if(!ans)
		{
			out.println("No");
			out.close();
			return;
		}
		int[][] dist = new int[k][k];
		for(int i = 0; i < k; i ++)
			Arrays.fill(dist[i], 987654321);
		compress();
		int[][] vis = new int[count][count];
		for(int i = 0; i < count; i ++)
		{
			dijkstras(i, compressed);
			for(int j = 0; j < count; j ++)
				vis[i][j] = ds[j];
		}
		
		for(int i = 0; i < k; i ++)
			for(int j = 0; j < k; j ++)
				dist[i][j] = vis[id[csum[i]]][id[csum[j]]];
		
		out.println("Yes");
		for(int i = 0; i < k; i ++)
		{
			for(int j = 0; j < k; j ++)
				out.print((dist[i][j] == 987654321?-1:dist[i][j])+" ");
			out.println();
		}
		out.close();
	}
	
	static int[] csum;
	static int[] prev;
	static int[] ds;

	static void dijkstras(int start, ArrayList<Edge>[] g) 
	{
		int n = g.length;
		prev = new int[n];
		Arrays.fill(prev, -1);
		ds = new int[n];
		Arrays.fill(ds, 987654321);
		ds[start] = 0;
		PriorityQueue<Node> pq = new PriorityQueue<Node>();
		pq.add(new Node(start, 0));

		while (!pq.isEmpty()) 
		{
			Node at = pq.poll();
			if (ds[at.at] < at.d)
				continue;
			for (Edge e : g[at.at]) 
			{
				int to = e.to;
				int nd = at.d + e.val;
				if (nd >= ds[to])
					continue;

				ds[to] = nd;

				prev[to] = at.at;

				pq.add(new Node(to, nd));
			}
		}
	}

	static class Node implements Comparable<Node> 
	{
		int at;
		int d;

		public Node(int aa, int dd) 
		{

			at = aa;
			d = dd;
		}

		public int compareTo(Node o) 
		{
			return (int) Long.signum(d - o.d);
		}
	}

	static class Edge
	{
		int to;
		int val;
		Edge(int to, int val)
		{
			this.to=to;
			this.val=val;
		}
	}
	static ArrayList<Edge>[] compressed;
	static ArrayList<Integer>[] adj;
	static ArrayList<Edge>[] edges;
	static int[] c;
	static boolean[] marked;
	static int[] id, low, stk;
	static int pre, count;
	static int k;
	static int n;
	static void compress()
	{
		compressed = new ArrayList[count];
		for(int i = 0; i < count; i ++)
		 compressed[i] = new ArrayList<Edge>();
		for(int i = 0; i < n; i ++)
			for(Edge e: edges[i])
				compressed[id[i]].add(new Edge(id[e.to], e.val));
	}
	static void scc()
	{
	    id = new int[adj.length]; low = new int[adj.length]; stk = new int[adj.length+1];
	    pre = count = 0;
	    marked = new boolean[adj.length];
	    for(int i =0; i<adj.length; i++)
	        if(!marked[i]) dfs(i);
	}
	static void dfs(int i)
	{
	    marked[stk[++stk[0]]=i] = true;
	    int min = low[i] = pre++;
	    for(int j: adj[i])
	    {
	        if(!marked[j]) dfs(j);
	        if(low[j] < min) min = low[j];
	    }
	    if(min < low[i]) low[i] = min;
	    else
	    {
	        while(stk[stk[0]] != i)
	        {
	            int j =stk[stk[0]--];
	            id[j] = count;
	            low[j] = adj.length;
	        }
	        id[stk[stk[0]--]] = count++;
	        low[i] = adj.length;
	    }
	}
	public static class in {
		static BufferedReader reader;
		static StringTokenizer tokenizer;
		static void init(InputStream in) {
			reader = new BufferedReader(
			new InputStreamReader(in));
			tokenizer = new StringTokenizer("");
		}
		static String next() throws IOException {
			while (!tokenizer.hasMoreTokens()) {
				tokenizer = new StringTokenizer(
				reader.readLine());
			}
			return tokenizer.nextToken();
		}
		static int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		static double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		static long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}