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.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Random;

public class A {

    public static final int INF = Integer.MAX_VALUE / 4;

    // 14:05-(15:15)-
    public static void main(String[] args) {
        try (PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {
            _Scanner sc = new _Scanner(System.in);

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

            int[] c = new int[k];
            for (int i = 0; i < c.length; i++) c[i] = sc.nextInt();

            ArrayList[] g = new ArrayList[n];
            for (int i = 0; i < g.length; i++) g[i] = new ArrayList();

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

                g[u].add(new Edge(v, x));
                g[v].add(new Edge(u, x));
            }

            LinkedList<Integer> order = new LinkedList<>();
            boolean[] seen = new boolean[n];
            for (int i = 0; i < g.length; i++) {
                dfs1(g, i, order, seen);
            }

//            System.out.println(String.format("order = %s", order));

            int[] uf = new int[n];
            for (int i = 0; i < uf.length; i++) uf[i] = i;

            seen = new boolean[n];
            for (Integer i : order) {
                dfs2(g, i, seen, uf);
            }

//            System.out.println(Arrays.toString(uf));

            int[] sums = new int[k + 1];
            for (int i = 0; i < c.length; i++) sums[i + 1] = sums[i] + c[i];

            HashMap[] cg = new HashMap[k];
            for (int i = 0; i < cg.length; i++) cg[i] = new HashMap();

            for (int i = 0; i < c.length; i++) {
                Integer par = null;
                for (int j = 0; j < c[i]; j++) {
                    int l = sums[i] + j;
                    if (par == null) {
                        par = uf[l];
                    } else if (par != uf[l]) {
                        out.println("No");
                        return;
                    }

                    HashMap<Integer, Integer> edges = cg[i];
                    ArrayList<Edge> arrayList = g[l];
                    for (Edge edge : arrayList) {
                        int otherSCC = parent(uf, edge.t);
                        edges.merge(otherSCC, edge.x, Math::min);
                    }
                }
            }

            int[][] dist = new int[k][k];
            for (int[] ints : dist) Arrays.fill(ints, INF);
            
            for (int i = 0; i < cg.length; i++) {
                for (int j = 0; j < k; j++) {
                    dist[i][j] = (int) cg[i].getOrDefault(parent(uf, sums[j]), INF);
                }
            }
            for (int i = 0; i < k; i++) dist[i][i] = 0;

            for (int i = 0; i < cg.length; i++) {
                for (int j = 0; j < cg.length; j++) {
                    for (int l = 0; l < cg.length; l++) {
                        dist[j][l] = Math.min(dist[j][l], dist[j][i] + dist[i][l]);
                    }
                }
            }

            out.println("Yes");
            for (int[] ints : dist) {
                for (int x : ints) {
                    out.print((x >= INF ? -1 : x) + " ");
                }
                out.println();
            }

//            for (HashMap hashMap : cg) {
//                System.out.println(String.format("hashMap = %s", hashMap));
//                for (int i = 0; i < k; i++) {
//                    Integer x = (Integer) hashMap.getOrDefault(k, -1);
//                    out.print((x >= INF ? -1 : x) + " ");
//                }
//                out.println();
//            }
        }
    }

    private static void dfs2(ArrayList[] rg, Integer n, boolean[] seen, int[] uf) {
        if (seen[n]) return;

        seen[n] = true;
        ArrayList<Edge> vs = rg[n];
        for (Edge v : vs) if (!seen[v.t] && v.x == 0) {
            uf[v.t] = parent(uf, n);
            dfs2(rg, v.t, seen, uf);
        }
    }

    private static int parent(int[] uf, Integer n) {
        if (uf[n] != n) uf[n] = parent(uf, uf[n]);
        return uf[n];
    }

    private static void dfs1(ArrayList[] g, int n, LinkedList<Integer> order, boolean[] seen) {
        if (seen[n]) return;

        seen[n] = true;
        ArrayList<Edge> vs = g[n];
        for (Edge v : vs) if (!seen[v.t] && v.x == 0) {
            dfs1(g, v.t, order, seen);
        }
        order.addFirst(n);
    }

    private static class Edge {
        int t, x;

        public Edge(int t, int x) {
            this.t = t;
            this.x = x;
        }
    }




    private static void reverse(int[] vs) {
        for (int i = 0; i < vs.length / 2; i++) {
            swap(vs, i, vs.length - 1 - i);
        }
    }

    static class _Scanner {
        InputStream is;
        _Scanner(InputStream is) {
            this.is = is;
        }
        byte[] bb = new byte[1 << 15];
        int k, l;
        byte getc() {
            try {
                if (k >= l) {
                    k = 0;
                    l = is.read(bb);
                    if (l < 0) return -1;
                }
                return bb[k++];
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        byte skip() {
            byte b;
            while ((b = getc()) <= 32)
                ;
            return b;
        }

        int nextInt() {
            int n = 0;
            int sig = 1;
            for (byte b = skip(); b > 32; b = getc()) {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            }
            return sig * n;
        }

        long nextLong() {
            long n = 0;
            long sig = 1;
            for (byte b = skip(); b > 32; b = getc()) {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            }
            return sig * n;
        }

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

        public String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); b > 32; b = getc()) {
                sb.append(((char) b));
            }
            return sb.toString();
        }
    }

    private static void shuffle(int[] ar) {
        Random rnd = new Random();
        shuffle(ar, rnd);
    }

    private static void shuffle(int[] ar, Random rnd) {
        for (int i = 0; i < ar.length; i++) {
            int j = i + rnd.nextInt(ar.length - i);
            swap(ar, i, j);
        }
    }

    private static void shuffle(Object[] ar) {
        Random rnd = new Random();
        for (int i = 0; i < ar.length; i++) {
            int j = i + rnd.nextInt(ar.length - i);
            swap(ar, i, j);
        }
    }

    private static void swap(int[] ar, int i, int j) {
        int t = ar[i];
        ar[i] = ar[j];
        ar[j] = t;
    }

    private static void swap(Object[] ar, int i, int j) {
        Object t = ar[i];
        ar[i] = ar[j];
        ar[j] = t;
    }

}