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 javafx.scene.layout.Priority;

import java.io.*;
import java.net.Inet4Address;
import java.util.*;
import java.lang.*;
import java.util.HashMap;
import java.util.PriorityQueue;
public class templ implements Runnable {
    public class triplet
    {
        int f,s,t;
        triplet(int f,int s,int t)
        {
            this.f=f;
            this.s=s;
            this.t=t;
        }
        public boolean equals(Object o)
        {
            triplet ob=(triplet)o;
            int ff,ss,tt;
            if(o!=null)
            {
                ff=ob.f;
                ss=ob.s;
                tt=ob.t;
                if((ff==this.f)&&(ss==this.s)&&(tt==this.t))
                    return true;
            }
            return false;
        }
        public int hashCode()
        {
            return (this.f+" "+this.s+" "+this.t).hashCode();
        }
    }
    public class pair implements Comparable
    {
        int f;
        int s;
        pair(int f,int s)
        {
            this.f=f;
            this.s=s;
        }
        public boolean equals(Object o)
        {
            pair ob=(pair)o;
            int ff;
            int ss;
            if(o!=null)
            {
                ff=ob.f;
                ss=ob.s;
                if((ff==this.f)&&(ss==this.s))
                    return true;
            }
            return false;
        }
        public int hashCode()
        {
            return (this.f+" "+this.s).hashCode();
        }
        public int compareTo(Object o)
        {
            pair pr=(pair)o;
            if(s>pr.s)
                return 1;
            else
                return -1;
        }
    }
    ArrayList<Integer>g[];
    int vis[];
    ArrayList<pair>g1[];
    int x=0;
    void dfs(int u)
    {
        vis[u]=x;
        //System.out.println(u+" "+vis[u]);
        for(int v : g[u])
        {
            if(vis[v]==0)
                dfs(v);
        }
    }
    public static void main(String args[])throws Exception
    {
        new Thread(null,new templ(),"templ",1<<27).start();
    }
    public void run() {
        try {
            InputReader in = new InputReader(System.in);
            PrintWriter out = new PrintWriter(System.out);
            int n=in.ni();
            int m=in.ni();
            int k=in.ni();
            g=new ArrayList[n+1];
            g1=new ArrayList[k+1];
            vis=new int[n+1];
            for(int i=1;i<=n;i++)
            {
                g[i]=new ArrayList<>();
                if(i<=k)
                    g1[i]=new ArrayList<>();
            }
            int a[]=new int[k+1];
            int b[]=new int[n+1];
            int p=1;
            for(int i=1;i<=k;i++)
            {
                a[i]=in.ni();
                for(int j=1;j<=a[i];j++)
                {
                    b[p]=i;
                    p++;
                }
            }
            for(int i=1;i<=m;i++)
            {
                int u=in.ni();
                int v=in.ni();
                int w=in.ni();
                if(w==0)
                {
                    g[u].add(v);
                    g[v].add(u);
                }
                int uu=b[u];
                int vv=b[v];
                if(uu==vv)
                    continue;
                g1[uu].add(new pair(vv,w));
                g1[vv].add(new pair(uu,w));
            }
            for(int i=1;i<=n;i++)
            {
                if(vis[i]==0)
                {
                    //System.out.println(i);
                    x++;
                    dfs(i);
                }
            }
            /*for(int i=1;i<=n;i++)
                out.println(i+" "+vis[i]+" ");*/
            //out.println();
            int kk=0;
            p=1;
            for(int i=1;i<=k;i++)
            {
                for(int j=1;j<a[i];j++)
                {
                    if(vis[p]!=vis[p+1])
                    {
                        kk=1;
                        break;
                    }
                    p++;
                }
                p++;
            }
            if(kk==1)
                out.println("No");
            else
            {
                out.println("Yes");
                int dist[][]=new int[k+1][k+1];
                for(int i=1;i<=k;i++)
                {
                    for(int j=1;j<=k;j++)
                        dist[i][j]=2000000000;
                    dist[i][i]=0;
                    PriorityQueue<pair>pq=new PriorityQueue<>();
                    for(int j=1;j<=k;j++)
                    {
                        pq.add(new pair(j,dist[i][j]));
                    }
                    int c[]=new int[k+1];
                    while(!pq.isEmpty())
                    {
                        pair pp=pq.remove();
                        int u=pp.f;
                        if(c[u]==1)
                            continue;
                        c[u]=1;
                        for(pair pa : g1[u])
                        {
                            int v=pa.f;
                            int w=pa.s;
                            if(dist[i][v]>dist[i][u]+w)
                            {
                                dist[i][v]=dist[i][u]+w;
                                pq.add(new pair(v,dist[i][v]));
                            }
                        }
                    }
                }
                for(int i=1;i<=k;i++)
                {
                    for(int j=1;j<=k;j++)
                    {
                        if(dist[i][j]==2000000000)
                            out.print("-1 ");
                        else
                            out.print(dist[i][j]+" ");
                    }
                    out.println();
                }
            }
            out.close();
        }
        catch(Exception e){
            return;
        }
    }
    static class InputReader {

        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int ni() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nl() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }

    }
}