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.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class q5 {
	static ArrayList<Integer>[] gph;
	static HashMap<Integer,Integer>[] gph2;
	static int[] visited;
	 
	static void dfs(int i,int num) {
		visited[i]=num;
		for(int x:gph[i]) {
			if(visited[x]==0) {
				dfs(x,num);
			}
		}
	}
	
	
	public static void main(String[] args) throws IOException {
		
		Reader.init(System.in);
		PrintWriter out=new PrintWriter(System.out);
		StringBuffer output=new StringBuffer("");
		int n=Reader.nextInt(),m=Reader.nextInt(),k=Reader.nextInt();
		gph=new ArrayList[n+1];
		gph2=new HashMap[k+1];
		int[][] range=new int[k+1][2];
		HashMap<Integer,Integer> comp=new HashMap<Integer,Integer>();
		
		for(int i=1;i<=n;i++) {
			gph[i]=new ArrayList<Integer>();
	
		}
		for(int i=1;i<=k;i++) {
			gph2[i]=new HashMap<Integer,Integer>();
		}
		int index=1;
		for(int i=0;i<k;i++) {
			int a=Reader.nextInt();
			for(int j=index;j<index+a;j++) {
				comp.put(j, i+1);
			}
			range[i+1][0]=index;
			range[i+1][1]=index+a-1;
			index=index+a;
			
		}
		
		for(int i=0;i<m;i++) {
			int a=Reader.nextInt(),b=Reader.nextInt(),x=Reader.nextInt();
			if(x==0) {
				gph[a].add(b);gph[b].add(a);
			}
			int a1=comp.get(a);
			int a2=comp.get(b);
			if(a1!=a2) {
				if(!gph2[a1].containsKey(a2)) gph2[a1].put(a2, Integer.MAX_VALUE);
				if(!gph2[a2].containsKey(a1)) gph2[a2].put(a1, Integer.MAX_VALUE);
				gph2[a1].put(a2, Math.min(gph2[a1].get(a2),x));
				gph2[a2].put(a1, Math.min(gph2[a2].get(a1),x));
			}
			
		}
		visited=new int[n+1];
		boolean possible=true;
		for(int i=1;i<=n;i++) {
			if(visited[i]==0) {
				dfs(i,i);
			}
		}
		for(int i=1;i<=k;i++) {
			int val=visited[range[i][0]];
			for(int j=range[i][0];j<=range[i][1];j++) {
				if(visited[j]!=val) {
					possible=false;break;
				}
			}
		}
		if(possible) {
			output.append("Yes\n");
			for(int i=1;i<=k;i++) {
				long[] dist=new long[k+1];
				visited=new int[k+1];
				Arrays.fill(dist, Integer.MAX_VALUE);
				dist[i]=0;
				PriorityQueue<NoD> pq=new PriorityQueue<NoD>(new Comparator<NoD>() {
					public int compare(NoD a,NoD b) {
					return Long.compare(a.b, b.b);
					}
				});
				pq.add(new NoD(i,0));
				while(pq.size()!=0) {
					NoD a=pq.poll();
					visited[(int)a.a]=1;
					for(int x:gph2[(int)a.a].keySet()) {
						if(visited[x]==0) {
							long y=gph2[(int)a.a].get(x);
							if(dist[x]>dist[(int)a.a]+y) {
								dist[x]=dist[(int)a.a]+y;
								pq.add(new NoD(x,dist[x]));
							}
						}
					}
				}
				for(int j=1;j<=k;j++) {
					if(dist[j]==Integer.MAX_VALUE) dist[j]=-1;
					output.append(dist[j]+" ");
				}
				output.append("\n");
			}
		}
		else {
			output.append("No");
		}
		out.write(output.toString());
		out.flush();
		
	}
}
class NoD{
	long a,b;
	String s;
	char c;
	NoD(long aa,long bb){
		a=aa;b=bb;
		s=a+" "+b;
		//c=cc;
	}
	@Override
	public boolean equals(Object o) {
		if(o!=null && o.getClass()==getClass()) {
			NoD c= (NoD) o;
			return c.a==a && c.b==b;
		}
		return false;
	}
	@Override
	public int hashCode() {
		return s.hashCode();
	}
}

class DisJoint{
	 int[] parent,rank;
	 DisJoint(int n){
		 parent=new int[n+1];
		 rank=new int[n+1];
		 for(int i=1;i<=n;i++) {
			 rank[i]=0;
			 parent[i]=i;
		 }
	 }
	void union(int a, int b) {
		int p1=find(a);
		int p2=find(b);
		if(p1!=p2) {
			if(rank[p1]>=rank[p2]) {
				parent[p2]=p1;
				if(rank[p1]==rank[p2]) rank[p1]++;
			}
			else {
				parent[p1]=p2;
			}
		}
	}
	
	int find(int a) {
		if(a!=parent[a]) {
			parent[a]=find(parent[a]);
		}
		return parent[a];
	}
}

//class Seg{
//	ArrayList<Integer> arr;
//	int[] segtree;
//	Seg(ArrayList<Integer> a){
//		arr=a;
//		int n=arr.size();
//		segtree=new int[4*n+1];
//	}
//	
//	void build(int index, int l, int r) {
//		if(l==r) {
//			segtree[index]=q5.occurance[arr.get(l)];
//		}
//		else {
//			int middle=(l+r)/2;
//			build(2*index+1,l,middle);
//			build(2*index+2,middle+1,r);
//			segtree[index]=Math.min(segtree[2*index+1], segtree[2*index+2]);
//		}
//	}
//	
//	int query(int index, int l, int r, int ql, int qr) {
//		if(ql<=l && r<=qr) {
//			return segtree[index];
//		}
//		else if(qr<l || ql>r) {
//			return Integer.MAX_VALUE;
//		}
//		else {
//			int middle=(l+r)/2;
//			int left=query(2*index+1,l,middle,ql,qr);
//			int right=query(2*index+2,middle+1,r,ql,qr);
//			return Math.min(left, right);
//		}
//	}
//}
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;
 
    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }
 
    /** get next word */
    static String nextLine() throws IOException{
    	return reader.readLine();
    }
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }
    
    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}