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.*;

public class D {
    public static void main (String[] args) {
        FastScanner fs = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        int n = fs.nextInt();
        int m = fs.nextInt();
        int k = fs.nextInt();

        ArrayList<Edge> list = new ArrayList<>();
        int[] comp = new int[n];
        int at = 0;
        int[] abc = fs.nextIntArray(k);
        for(int i = 0; i < k; i++) {
            for(int j = 0; j < abc[i]; j++) {
                comp[at++] = i;
            }
        }

        ArrayList<Edge>[] forDFS = new ArrayList[n];
        init(forDFS);

        Edge[][] adj = new Edge[k][k];
        for(int i = 0; i < m; i++) {
            int u = fs.nextInt()-1; int v = fs.nextInt()-1;
            int we = fs.nextInt();
            list.add(new Edge(u, v, we));
            forDFS[u].add(new Edge(u, v, we));
            forDFS[v].add(new Edge(v, u, we));
            u = comp[u]; v = comp[v];
            if(u == v) continue;
            if(adj[u][v] == null) {
                adj[u][v] = new Edge(u, v, we);
                adj[v][u] = new Edge(v, u, we);
            } else {
                if(we < adj[u][v].we) {
                    adj[u][v] = new Edge(u, v, we);
                }
                if(we < adj[v][u].we) {
                    adj[v][u] = new Edge(v, u, we);
                }
            }
        }


        Collections.sort(list);
        boolean[] V = new boolean[n];
        boolean noZero = false;
        int[] cnt = new int[k];
        for(Edge e : list) {
            if(e.we > 0) break;
            if(V[e.u]) continue;
            V[e.u] = true;
            ArrayList<Integer> seen = new ArrayList<>();
            boolean[] s = new boolean[k];
            dfs(e.u, V, cnt, forDFS, comp, seen, s);
            for(Integer i : seen) {
                if(cnt[i] < abc[i]) {
                    noZero = true;
                    break;
                }
            }
        }

        for(int i = 0; i < k && !noZero; i++)
            if(cnt[i] < abc[i] && abc[i] != 1) noZero = true;

//        System.out.println(Arrays.toString(cnt) + " " + Arrays.toString(abc));

        if(noZero) {
            out.println("No");
            out.close();
            return;
        }

        int oo = (int)2e9;
        int[][] floyd = new int[k][k];
        for(int i = 0; i < k; i++)
            for(int j = 0; j < k; j++)
                floyd[i][j] = oo;

        for(int i= 0; i < k; i++)
            floyd[i][i] = 0;

        for(int i = 0; i < k; i++)
            for(int j = 0; j < k; j++)
                if(adj[i][j] != null)
                    floyd[i][j] = adj[i][j].we;

        for(int fl = 0; fl < k; fl++)
            for(int i = 0; i < k; i++)
                for(int j = 0; j < k; j++) {
                    if(floyd[i][fl] == oo || floyd[fl][j] == oo) continue;
                    int check = floyd[i][fl] + floyd[fl][j];
                    if(check < floyd[i][j]) floyd[i][j] = check;
                }

        out.println("Yes");

        for(int i = 0; i < k; i++) {
            for(int j = 0; j < k; j++) {
                if(j > 0) out.print(" ");
                if(floyd[i][j] == oo) out.print(-1);
                else out.print(floyd[i][j]);
            }
            out.println();
        }

        out.close();
    }

    static void dfs (int at, boolean[] V, int[] cnt, ArrayList<Edge>[] adj, int[] comp, ArrayList<Integer> seen, boolean[] s) {
        cnt[comp[at]]++;
        if(!s[comp[at]]) {
            s[comp[at]] = true;
            seen.add(comp[at]);
        }
        for(Edge e : adj[at]) {
            if(V[e.v]) continue;
            if(e.we > 0) continue;
            V[e.v] = true;
            dfs(e.v, V, cnt, adj, comp, seen, s);
        }
    }

    private static void init(ArrayList<Edge>[] adj) {
        for(int i = 0; i < adj.length; i++) adj[i] = new ArrayList<>();
    }

    static class Edge implements Comparable<Edge> {
        int u, v;
        int we;
        Edge (int a, int b, int c) {
            u = a; v = b;
            we = c;
        }

        public int compareTo(Edge o) {
            if(we == o.we) return Integer.compare(u, o.u);
            return Integer.compare(we, o.we);
        }
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try	{
                br = new BufferedReader(new InputStreamReader(System.in));
//                br = new BufferedReader(new FileReader("testdata.out"));
                st = new StringTokenizer("");
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens())	return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

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

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

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

        public String nextLine() {
            String line = "";
            try {line = br.readLine();}
            catch (Exception e) {e.printStackTrace();}
            return line;
        }

        public Integer[] nextIntegerArray(int n) {
            Integer[] a = new Integer[n];
            for(int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

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

        public char[] nextCharArray() {
            return nextLine().toCharArray();
        }
    }

}