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.*; 
import java.math.*;
import java.io.*;
import java.text.DecimalFormat;
import java.math.BigInteger;
public class Main{
    static int d=20,n;
    static int mod=1000000007 ;
    static  ArrayList<ArrayList<Integer>> arr;
    static int[] a,b,c; 
    public static void main(String[] args)  throws IOException {
        s.init(System.in);   
        
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int n,m,k;
        n=s.ni();
        m=s.ni();
        k=s.ni();
        int[] a=new int[k];
        for(int i=0;i<k;i++)
            a[i]=s.ni();
        int[] type=new int[n];
        int p=0;
        for(int i=0;i<k;i++)
            for(int j=0;j<a[i];j++)
                type[p++]=i;
        int[][] energy=new int[m][];
        for(int i=0;i<m;i++){
            energy[i]=new int[]{s.ni()-1,s.ni()-1,s.ni()};
        }
        dj d=new dj(n);
        for(int i=0;i<m;i++){
            if(energy[i][2]==0)
                d.union(energy[i][0],energy[i][1]);
        }
        int flag=0;
        for(int i=0;i<n-1;i++){
            if(type[i]==type[i+1]){
                if(!d.equals(i,i+1)){
                    out.println("No");
                    flag=1;
                    break;
                }
                    
            }
        }
        if(flag==0){
            int[][] ans=new int[k][k];
            for(int i=0;i<k;i++)
                Arrays.fill(ans[i],Integer.MAX_VALUE/2);
            for(int i=0;i<k;i++){
                ans[i][i]=0;
            }
            for(int i=0;i<m;i++){
                int x,y;
                x=type[energy[i][0]];
                y=type[energy[i][1]];

                ans[x][y]=ans[y][x]=Math.min(ans[x][y],energy[i][2]);
            }
            for(int i=0;i<k;i++){
                for(int j=0;j<k;j++){
                    for(int l=0;l<k;l++){
                        ans[j][l]=Math.min(ans[j][l],ans[j][i]+ans[i][l]);
                    }
                }
            }
            out.println("Yes");
            for(int i=0;i<k;i++){
                for(int j=0;j<k;j++){
                    if(ans[i][j]==Integer.MAX_VALUE/2){
                        out.print("-1 ");
                    }
                    else
                        out.print(ans[i][j]+" ");
                }
                out.println("");
            }
        }
        out.close();
    }

                

    static class dj{
        int[] p;
        int[] size;
        public dj(int n){
            p=new int[n];
            size=new int[n];
            for(int i=0;i<n;i++)
                p[i]=i;
            Arrays.fill(size,1);
        }
        public boolean equals(int x,int y){
            return parent(x)==parent(y);
        }
        public int parent(int x){
            if(x!=p[x])
                return parent(p[x]);
            else
                return x;
        }

        public void union(int x,int y){
            x=parent(x);
            y=parent(y);
            if(size[x]<size[y]){
                int d=x;
                x=y;
                y=d;

            }
            size[x]+=size[y];
            p[y]=x;
        }


    }    
    public static class s {
        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 ns() throws IOException {
            while ( ! tokenizer.hasMoreTokens() ) {
                //TODO add check for eof if necessary
                tokenizer = new StringTokenizer(
                    reader.readLine() );
            }
            return tokenizer.nextToken();
        }
 
        static int ni() throws IOException {
            return Integer.parseInt( ns() );
        }
    
        static double nd() throws IOException {
            return Double.parseDouble( ns() );
        }
        static long nl() throws IOException {
            return Long.parseLong( ns() );
        }
        
    }
}