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.awt.Checkbox;
import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;


public class D2 {
 static int []a;
 static int n;
 static int m;
 static int k;
 static Dsu dsu;
 static long [][]res;
 static final long inf =(long)1e10;
    public static void main(String[] args)throws Exception {
        n=in();
        m=in();
        k=in();
        LinkedList<Point>l=new LinkedList<>();
        res=new long[k][k];
        for (int i=0;i<k;i++)
            for (int j=0;j<k;j++)res[i][j]=i==j?0:inf;
        
        a=new int [n];
        for (int i=0;i<k;i++){
            l.addLast(new Point(in(),i));
        }
        int j=0;
        while (!l.isEmpty()){
            if (l.getFirst().x==0){
                l.removeFirst();
                continue;
            }
            a[j++]=l.getFirst().y;
            l.getFirst().x--;
        }
         dsu =new Dsu(n);
        PriorityQueue<tri>q=new PriorityQueue<>();
        for (int i=0;i<m;i++){
            q.offer(new tri(in()-1,in()-1,in()));
        }
        boolean x=true;
    //  pr();
        while (!q.isEmpty()){
            if (q.peek().d>0)break;
            int f=q.peek().from;
            int t=q.peek().to;
            q.poll();
            if (a[f]!=a[t])res[a[f]][a[t]]=res[a[t]][a[f]]=0;
            if (dsu.isSameSet(f, t))continue;
            dsu.union(f, t);
            
        }
        x=check();
        if (!x){
            System.out.println("No");
            return;
        }
        while (!q.isEmpty()){
            int f=q.peek().from;
            int t=q.peek().to;
            int d=q.peek().d;
            //System.out.println(f+" "+t+" "+d+"***");
            q.poll();
            if (a[f]!=a[t])res[a[f]][a[t]]=res[a[t]][a[f]]=Math.min(res[a[f]][a[t]],d);
            if (dsu.isSameSet(f, t))continue;
            dsu.union(f, t);
        }
        //pr();
        for (int v=0;v<k;v++)
            for (int i=0;i<k;i++)
                for(j=0;j<k;j++)res[i][j]=Math.min(res[i][j],res[i][v]+res[v][j]);
        System.out.println("Yes");
        pr();
                

    }
    static void pr(){
        for (int i=0;i<k;i++){
            for (int j=0;j<k;j++)System.out.print((res[i][j]==inf?-1:res[i][j])+" ");
            System.out.println();
        }
        //System.out.println();
    }
    private static boolean check() {
        int t=-1;
        int p=-1;
        for (int i=0;i<n;i++){
            if (a[i]!=t){
                t=a[i];
                p=dsu.findSet(i);
            }else{
                if (dsu.findSet(i)!=p)return false;
            }
        }
        return true;
    }
    static BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;
    static int in() throws IOException{
        if (st==null || !st.hasMoreTokens()){
            st=new StringTokenizer(buf.readLine());
        }
        return Integer.parseInt(st.nextToken());
    }
    static long ll() throws IOException{
        if (st==null || !st.hasMoreTokens()){
            st=new StringTokenizer(buf.readLine());
        }
        return Long.parseLong(st.nextToken());
    }
    static String str() throws IOException{
        if (st==null || !st.hasMoreTokens()){
            st=new StringTokenizer(buf.readLine());
        }
        return (st.nextToken());
    }
        static double dub() throws IOException{
            if (st==null || !st.hasMoreTokens()){
                st=new StringTokenizer(buf.readLine());
            }
            return Double.parseDouble(st.nextToken());
    }
}


class Dsu{
    int []p;
    int []rank;
    Dsu(int n){
        p=new int [n];
        rank=new int [n];
        for (int i=0;i<n;i++)p[i]=i;
    }
    int findSet(int i){return p[i]==i?i:(p[i]=findSet(p[i]));}
    boolean isSameSet(int i,int j){return findSet(i)==findSet(j);}
    void union(int i,int j){
        if (!isSameSet(i, j)){
            int x=findSet(i); int y=findSet(j);
            if (rank[x]>rank[y])p[y]=x;
            else{
                p[x]=y;
                if (rank[x]==rank[y])rank[y]++;
            }
        }
    }
}
class tri implements Comparable<tri>{
      int from;
      int to;
      int d;
     tri(int f,int t,int dd){
         from=f;
         to=t;
         d=dd;
     }
    public int compareTo(tri o) {
        return d-o.d;
    }
    
}