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.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class DimaandBacteria
{
    public static void print(String str,int val){
        System.out.println(str+"  "+val);
    }

    public int gcd(int a, int b) {
        if (b==0) return a;
        return gcd(b,a%b);
    }

    public static void debug(long[][] arr){
        int len = arr.length;
        for(int i=0;i<len;i++){
            System.out.println(Arrays.toString(arr[i]));
        }
    }
    public static void debug(int[][] arr){
        int len = arr.length;
        for(int i=0;i<len;i++){
            System.out.println(Arrays.toString(arr[i]));
        }
    }
    public static void debug(String[] arr){
        int len = arr.length;
        for(int i=0;i<len;i++){
            System.out.println(arr[i]);
        }
    }

    public static void print(int[] arr){
        int len = arr.length;
        for(int i=0;i<len;i++){
            System.out.print(arr[i]+" ");
        }
        System.out.print('\n');
    }
    public static void print(String[] arr){
        int len = arr.length;
        for(int i=0;i<len;i++){
            System.out.print(arr[i]+" ");
        }
        System.out.print('\n');
    }
    public static void print(long[] arr){
        int len = arr.length;
        for(int i=0;i<len;i++){
            System.out.print(arr[i]+" ");
        }
        System.out.print('\n');
    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }
        public FastReader(String path) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(path));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    static pair[] edges;
    static ArrayList<Integer>[] zeroTree;
    static int[] color;
    public static void main(String[] args) throws IOException {
        FastReader s=new FastReader();
        int n = s.nextInt();
        int m = s.nextInt();
        int k = s.nextInt();
        int[] c = new int[k];
        for(int i=0;i<k;i++){
            c[i] = s.nextInt();
        }
        edges = new pair[m];
        zeroTree = new ArrayList[n];
        color = new int[n];

        for(int i=0;i<n;i++){
            zeroTree[i] = new ArrayList<>();
        }

        for(int i=0;i<m;i++){
            int u = s.nextInt()-1;
            int v = s.nextInt()-1;
            int w = s.nextInt();

            edges[i] = (new pair(u,v,w));
            if(w==0){
                zeroTree[u].add(v);
                zeroTree[v].add(u);
            }
        }
        if(m==0){
//            boolean all_same = true;
            for(int i=0;i<k;i++){
                if(!((c[i]==1) || (c[i]==0))){
                    System.out.println("No");
                    return;
                }
            }
            System.out.println("Yes");
            OutputStream out = new BufferedOutputStream( System.out );
            for(int i=0;i<k;i++){
                for(int j=0;j<k;j++){
                    if(i==j){
                        out.write((0+" ").getBytes());
                    }
                    else {
                        out.write((-1+" ").getBytes());
                    }
                }
                out.write('\n');
                out.flush();
            }

            return;
        }
        int start =0;
        for(int i=0;i<n;i++){
            if(color[i]==0){
                start++;
                color[i] = start;
                dfs(i,-1);
            }
        }
        //now check colors
//        print(color);
        int[] range = new int[n];
        int cnt = 0;
        int sum =0;
        boolean isTrue = true;
        for(int i=0;i<k;i++){
            int clr = color[sum];
            range[sum] = cnt;
            for(int j=1;j<c[i];j++){
                if(clr!=color[sum+j]){
                    isTrue = false;
                    break;
                }
                range[sum+j] = cnt;
            }
            if(!isTrue){
                break;
            }
            sum+=c[i];
            cnt++;
            if(sum==n){
                break;
            }
        }
        if(!isTrue){
            System.out.println("No");
            return;
        }
        System.out.println("Yes");
//        print(range);
        int[][] graph = new int[k][k];
        for(int i=0;i<k;i++){
            Arrays.fill(graph[i],(int)(1e5));
        }
        for(pair edge:edges){
//            System.out.println(edge);
            int u = range[edge.u];
            int v=  range[edge.v];
            int w = edge.weight;
//            System.out.println(u+" "+v);
            if(u!=v){
                graph[u][v] = Math.min(graph[u][v],w);
                graph[v][u] = Math.min(graph[v][u],w);
            }

        }
        for(int i=0;i<k;i++){
            graph[i][i] = 0;
        }

        //floydd warshall
        int[][] dist = graph.clone();
//        debug(dist);
        for(int kk=0;kk<k;kk++){
            for(int i=0;i<k;i++){
                for(int j=0;j<k;j++){
                    if(dist[i][kk]+dist[kk][j]<dist[i][j]){
                        dist[i][j] = dist[i][kk]+dist[kk][j];
                    }
                }
            }
        }
        OutputStream out = new BufferedOutputStream( System.out );
        for(int i=0;i<k;i++){
            for(int j=0;j<k;j++){
                if(dist[i][j]==(int)(1e5)){
                    out.write((-1+" ").getBytes());
                }
                else {
                    out.write((dist[i][j]+" ").getBytes());
                }
            }
            out.write('\n');
            out.flush();
        }





    }
    static void dfs(int curr,int prev){
        for(int child:zeroTree[curr]){
            if(color[child]==0){
                color[child] = color[curr];
//                zeroParent[child] = curr;
                dfs(child,curr);
            }
        }
    }
    static class pair{
        int u;
        int v;
        int weight;
        pair(int u,int v,int weight){
            this.u =u;
            this.v = v;
            this.weight = weight;
        }

        @Override
        public String toString() {
            return  (u+" "+v+" "+weight);
        }
    }




//    OutputStream out = new BufferedOutputStream( System.out );
//        for(int i=1;i<n;i++){
//    out.write((arr[i]+" ").getBytes());
//}
//        out.flush();

    //  long start = System.currentTimeMillis();
//  long end = System.currentTimeMillis();
//  System.out.println((end - start) + "ms");



}