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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DDimaAndBacteria solver = new DDimaAndBacteria();
        solver.solve(1, in, out);
        out.close();
    }

    static class DDimaAndBacteria {
        private int n;
        private int m;
        private int k;
        private int[][] c;
        private HashMap<Integer, Integer> parents;
        private DDimaAndBacteria.DisjointSet ds;
        private int[][] redAdj;
        private long[][] redGraph;

        private int clusterNum(int ver) {
            return parents.get(ds.root(ver));
        }

        private void floydWarshall(int n) {
            for (int k = 1; k <= n; ++k) {
                for (int i = 1; i <= n; ++i) {
                    for (int j = 1; j <= n; ++j) {
                        redGraph[i][j] = Math.min(redGraph[i][j], redGraph[i][k] + redGraph[k][j]);
                    }
                }
            }
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            n = in.nextInt();
            m = in.nextInt();
            k = in.nextInt();
            c = new int[k + 1][2];
            for (int i = 1; i <= k; i++) {
                c[i][0] = in.nextInt();
                c[i][1] = i;
            }
            ArrayList<Util.Triplet<Integer>> ways = new ArrayList<>();
            ds = new DDimaAndBacteria.DisjointSet(n);
            for (int i = 0; i < m; i++) {
                int u = in.nextInt(), v = in.nextInt(), cost = in.nextInt();
                ways.add(new Util.Triplet<>(u, v, cost));
                if (cost == 0) ds.union(u, v);
            }
            if (ds.numOfSets > k) {
                out.println("No");
                return;
            }
            int curr = 1;
            ArrayList<ArrayList<Integer>> al = new ArrayList<>();
            for (int i = 1; i <= k; i++) {
                int num = c[i][0];
                al.add(new ArrayList<>());
                for (int j = 1; j <= num; j++) {
                    al.get(al.size() - 1).add(curr++);
                }
            }
            for (ArrayList<Integer> temp : al) {
                for (int i = 1; i < temp.size(); i++) {
                    if (!ds.isInSameSet(temp.get(i - 1), temp.get(i))) {
                        out.println("No");
                        return;
                    }
                }
            }
            Arrays.sort(c, Comparator.comparingInt(o -> o[0]));
            ArrayList<Util.Pair<Integer>> parentList = new ArrayList<>();
            for (int i = 1; i <= n; i++)
                if (ds.root(i) == i) {
                    parentList.add(new Util.Pair<>(i, ds.setSize[i]));
                }
            Collections.sort(parentList, Comparator.comparingInt(o -> o.y));
            parents = new HashMap<>();
            ArrayList<Integer> clusterSizes = new ArrayList<>();
            int cluster = 1;
            for (int i = 0; i < parentList.size(); i++) {
                parents.put(parentList.get(i).x, cluster++);
                clusterSizes.add(parentList.get(i).y);
            }
            int[] typeToCluster = new int[k + 1];
            int mark1 = 1, mark2 = 0, sum = 0;
            while (mark2 < clusterSizes.size()) {
                sum += c[mark1][0];
                typeToCluster[c[mark1][1]] = mark2 + 1;
                if (sum == clusterSizes.get(mark2)) {
                    mark1++;
                    mark2++;
                    sum = 0;
                } else if (sum > clusterSizes.get(mark2)) {
                    sum = 0;
                    mark2++;
                } else mark1++;
            }
            if (!(mark2 == clusterSizes.size() && mark1 == k + 1 && sum == 0)) {
                out.println("No");
                return;
            }
            redGraph = new long[clusterSizes.size() + 1][clusterSizes.size() + 1];

            redAdj = new int[k + 1][k + 1];
            for (int i = 1; i <= clusterSizes.size(); i++) {
                for (int j = 1; j <= clusterSizes.size(); j++) if (i != j) redGraph[i][j] = Integer.MAX_VALUE;
            }
            for (Util.Triplet<Integer> temp : ways) {
                int u = temp.x, v = temp.y, cost = temp.z;
                int cluster_u = clusterNum(u), cluster_v = clusterNum(v);
                if (!ds.isInSameSet(u, v)) {
                    redGraph[cluster_u][cluster_v] = Math.min(cost, redGraph[cluster_u][cluster_v]);
                    redGraph[cluster_v][cluster_u] = redGraph[cluster_u][cluster_v];
                }
            }
            floydWarshall(clusterSizes.size());
            for (int i = 1; i <= k; i++) {
                for (int j = 1; j <= k; j++) {
                    if (redGraph[typeToCluster[i]][typeToCluster[j]] == Integer.MAX_VALUE) redAdj[i][j] = -1;
                    else redAdj[i][j] = (int) redGraph[typeToCluster[i]][typeToCluster[j]];
                }
            }
            out.printf("%s\n", "Yes");
            for (int i = 1; i <= k; i++) {
                for (int j = 1; j <= k; j++) {
                    out.printf("%d ", redAdj[i][j]);
                }
                out.printf("\n");
            }
        }

        static class DisjointSet {
            private int[] parent;
            private int[] setSize;
            private int numOfSets;

            private DisjointSet(int n) {
                parent = new int[n + 1];
                setSize = new int[n + 1];
                for (int i = 1; i <= n; i++) {
                    parent[i] = i;
                    setSize[i] = 1;
                }
                numOfSets = n;
            }

            private int root(int x) {
                if (x == parent[x]) return x;
                return parent[x] = root(parent[x]);
            }

            private boolean isInSameSet(int n1, int n2) {
                return root(n1) == root(n2);
            }

            private boolean union(int n1, int n2) {
                return _union(root(n1), root(n2));
            }

            private boolean _union(int n1, int n2) {
                if (n1 == n2) return false;
                if (setSize[n1] > setSize[n2]) {
                    parent[n2] = parent[n1];
                    setSize[n1] += setSize[n2];
                } else {
                    parent[n1] = parent[n2];
                    setSize[n2] += setSize[n1];
                }
                numOfSets--;
                return true;
            }

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int numChars;

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

        public InputReader(FileInputStream file) {
            this.stream = file;
        }

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

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res = (res << 3) + (res << 1) + c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

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

    }

    static class Util {
        public static class Pair<T> {
            public T x;
            public T y;

            public Pair(T x, T y) {
                this.x = x;
                this.y = y;
            }

            public boolean equals(Object obj) {
                if (obj == this) return true;
                if (!(obj instanceof Util.Pair)) return false;
                Util.Pair<T> pair = (Util.Pair<T>) obj;
                return this.x == pair.x && this.y == pair.y;
            }

            public String toString() {
                return ("(" + this.x + "," + this.y + ")");
            }

            public int hashCode() {
                return (this.x + " " + this.y).hashCode();
            }

        }

        public static class Triplet<T> {
            public T x;
            public T y;
            public T z;

            public Triplet(T x, T y, T z) {
                this.x = x;
                this.y = y;
                this.z = z;
            }

            public boolean equals(Object obj) {
                if (obj == this) return true;
                if (!(obj instanceof Util.Triplet)) return false;
                Util.Triplet<T> triplet = (Util.Triplet<T>) obj;
                return this.x == triplet.x && this.y == triplet.y && this.z == triplet.z;
            }

            public String toString() {
                return ("(" + this.x + "," + this.y + "," + this.z + ")");
            }

            public int hashCode() {
                return (this.x + " " + this.y + " " + this.z).hashCode();
            }

        }

    }
}