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.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Solve6 {

    public static void main(String[] args) throws IOException {
        PrintWriter pw = new PrintWriter(System.out);
        new Solve6().solve(pw);
        pw.flush();
        pw.close();
    }

    public void solve(PrintWriter pw) throws IOException {
        FastReader sc = new FastReader();
        int n = sc.nextInt(), m = sc.nextInt(), k = sc.nextInt();
        int[] c = new int[k];
        for (int i = 0; i < k; i++) {
            c[i] = sc.nextInt();
        }
        Edge[] edges = inputUndirectedGraphByEdges(sc, m, true);
        ArrayList<Node>[] adj = inputGraphFromEdgesArray(edges, n);
        int j = 1;
        int[] parent = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            parent[i] = j;
            --c[j - 1];
            if (c[j - 1] == 0) {
                ++j;
            }
        }
        boolean[] vis = new boolean[j];
        for (int i = 1; i <= n; i++) {
            int p = parent[i];
            if (!vis[p]) {
                vis[p] = true;
                boolean[] vis2 = new boolean[n + 1];
                dfs(i, adj, vis2);
                for (int w = 1; w <= n; w++) {
                    if (p == parent[w] && !vis2[w]) {
                        pw.println("No");
                        return;
                    }
                }
            }
        }
        adj = mergeNodesWithSameTypeWithMinimumWeight(edges, parent);
        long[][] ans = floydWarshall(adj);
        pw.println("Yes");
        for (int i = 1; i <= k; i++) {
            for (int w = 1; w <= k; w++) {
                pw.print((ans[i][w] == Long.MAX_VALUE ? -1 : ans[i][w]) + (w == k ? "\n" : " "));
            }
        }
    }

    public long[][] floydWarshall(ArrayList<Node>[] adj) {
        int n = adj.length - 1;
        long[][] dist = new long[n + 1][n + 1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                if (i != j) {
                    dist[i][j] = Long.MAX_VALUE;
                }
            }
            for (Node temp : adj[i]) {
                int v = temp.v;
                long w = temp.w;
                dist[i][v] = w;
            }
        }

        for (int k = 1; k <= n; k++) {
            for (int i = 1; i <= n; i++) {
                if (i == k || dist[i][k] == Long.MAX_VALUE) {
                    continue;
                }
                for (int j = 1; j <= n; j++) {
                    if (i == j || j == k || dist[k][j] == Long.MAX_VALUE) {
                        continue;
                    }
                    if (dist[i][j] == Long.MAX_VALUE || dist[i][k] + dist[k][j] < dist[i][j]) {
                        dist[i][j] = dist[i][k] + dist[k][j];
                    }
                }
            }
        }
        return dist;
    }

    //build graph with all nodes with same type as one node
    //and connected by minimum weighted edges to nodes from other types
    //new graph may contains loops
    public ArrayList<Node>[] mergeNodesWithSameTypeWithMinimumWeight(Edge[] edges, int[] type) {
        int n = type.length;
        boolean[] typeVisited = new boolean[n];
        int typesNum = 0;
        for (int i = 1; i < n; i++) {
            if (!typeVisited[type[i]]) {
                typeVisited[type[i]] = true;
                ++typesNum;
            }
        }
        ArrayList<Node>[] newGraph = new ArrayList[typesNum + 1];
        TreeMap<Integer, Edge>[] tm = new TreeMap[typesNum + 1];
        for (int i = 1; i <= typesNum; i++) {
            newGraph[i] = new ArrayList();
            tm[i] = new TreeMap();
        }
        for (int i = 0; i < edges.length; i++) {
            int u = type[edges[i].u], v = type[edges[i].v];
            if (u > v) {
                u = v + u - (v = u);
            }
            long w = edges[i].w;
            long oldW = tm[u].get(v) == null ? Long.MAX_VALUE : tm[u].get(v).w;
            if (w < oldW) {
                tm[u].put(v, edges[i]);
            }
        }
        for (int i = 1; i <= typesNum; i++) {
            for (Map.Entry<Integer, Edge> entry : tm[i].entrySet()) {
                int v = entry.getKey();
                Edge edge = entry.getValue();
                newGraph[i].add(new Node(v, edge.index, edge.w));
                if (i != v) {
                    newGraph[v].add(new Node(i, edge.index, edge.w));
                }
            }
        }
        return newGraph;
    }

    public void dfs(int u, ArrayList<Node>[] adj, boolean[] vis) {
        vis[u] = true;
        for (Node nd : adj[u]) {
            int v = nd.v;
            long w = nd.w;
            if (w == 0 && !vis[v]) {
                dfs(v, adj, vis);
            }
        }
    }

    public Edge[] inputUndirectedGraphByEdges(FastReader sc, int m, boolean isWeighted) {
        Edge[] edges = new Edge[m];
        for (int i = 0; i < m; i++) {
            int u = sc.nextInt(), v = sc.nextInt();
            long w = 1;
            if (isWeighted) {
                w = sc.nextLong();
            }
            edges[i] = new Edge(u, v, w, i);
        }
        return edges;
    }

    public ArrayList<Node>[] inputGraphFromEdgesArray(Edge[] edges, int n) {
        ArrayList<Node>[] adj = new ArrayList[n + 1];
        for (int i = 1; i <= n; i++) {
            adj[i] = new ArrayList();
        }
        for (int i = 0; i < edges.length; i++) {
            int u = edges[i].u, v = edges[i].v, edgeIndex = edges[i].index;
            long w = edges[i].w;
            adj[u].add(new Node(v, edgeIndex, w));
            adj[v].add(new Node(u, edgeIndex, w));
        }
        return adj;
    }

    class Edge {

        int u, v, index;
        long w;

        public Edge(int u, int v, long w, int index) {
            this.u = u;
            this.v = v;
            this.w = w;
            this.index = index;
        }
    }

    class Node {

        int v, edgeIndex;
        long w;

        public Node(int v) {
            this.v = v;
            this.w = 1;
        }

        public Node(int v, int edgeIndex, long w) {
            this.v = v;
            this.edgeIndex = edgeIndex;
            this.w = w;
        }

        @Override
        public String toString() {
            return Integer.toString(this.v);
        }
    }

    static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
            }
        }

        public String next() {
            if (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                }
            }
            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() {
            try {
                return br.readLine();
            } catch (Exception e) {
            }
            return null;
        }

        public boolean hasNext() throws IOException {
            if (st != null && st.hasMoreTokens()) {
                return true;
            }
            String s = br.readLine();
            if (s == null || s.isEmpty()) {
                return false;
            }
            st = new StringTokenizer(s);
            return true;
        }
    }
}