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.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Round234_D {

    ArrayList<Integer> g[];
    int K;
    int all[];

    int find(int val) {

        int ans = 1 << 25;
        int low = 0;
        int high = K - 1;
        while (low <= high) {

            if (high - low <= 1) {
                if (low == high) {
                    if (val <= all[low]) {
                        ans = Math.min(ans, low);
                    }
                } else {
                    if (val <= all[low]) {
                        ans = Math.min(ans, low);
                    } else if (val <= all[high]) {
                        ans = Math.min(ans, high);
                    }
                }
                break;
            }
            int mid = low + (high - low) / 2;
            if (val <= all[mid]) {
                ans = Math.min(ans, mid);
                high = mid - 1;
            } else {
                low = mid + 1;
            }
        }
        return ans;
    }

    public void solve() throws Exception {
        InputReader in = new InputReader();

        int N = in.nextInt();
        int M = in.nextInt();
        K = in.nextInt();

        int sumtmp = 0;
        int arr[] = new int[K];
        all = new int[K];
        for (int i = 0; i < K; i++) {
            arr[i] = in.nextInt();
            sumtmp += arr[i];
            all[i] = sumtmp;
        }

        Disj dis = new Disj(N);
        g = new ArrayList[K];
        for (int i = 0; i < K; i++) {
            g[i] = new ArrayList<Integer>();
        }

        for (int i = 0; i < M; i++) {
            int from = in.nextInt() - 1;
            int to = in.nextInt() - 1;
            int c = in.nextInt();
            if (c == 0) {
                // System.out.println("union" + from + " " + to);
                dis.union(from, to);
            }
            int ff = find(from + 1);
            int tt = find(to + 1);
            g[ff].add(tt);
            g[ff].add(c);
            g[tt].add(ff);
            g[tt].add(c);
        }

        // check yes,no
        int prev = 0;
        for (int i = 0; i < K; i++) {
            int from = prev;
            int to = all[i];
            for (int j = from; j < to; j++) {
                if (!dis.areSameSet(from, j)) {
                    // System.out.println("ask "+from + " " + j);
                    System.out.println("No");
                    return;
                }
            }
            prev += arr[i];
        }
        StringBuffer ret = new StringBuffer();
        ret.append("Yes\n");
        // find an answer
        int[] dist;
        for (int i = 0; i < K; i++) {
            dist = shortestPath(i);
            ret.append((dist[0] == (1 << 25)) ? -1 : dist[0]);
            for (int j = 1; j < K; j++) {
                ret.append(" " + ((dist[j] == (1 << 25)) ? -1 : dist[j]));
            }
            ret.append("\n");
        }
        System.out.print(ret);
    }

    int[] shortestPath(int source) {
        int[] dist = new int[K];
        Arrays.fill(dist, 1 << 25);
        PriorityQueue<Node> q = new PriorityQueue<Node>();
        dist[source] = 0;
        q.add(new Node(source, dist[source]));
        while (!q.isEmpty()) {
            Node node = q.poll();
            int ind = node.index;
            int oldCost = node.cost;
            if (oldCost != dist[ind])
                continue;
            for (int j = 0; j < g[ind].size(); j += 2) {
                int to = g[ind].get(j);
                int newCost = dist[ind] + g[ind].get(j + 1);

                if (newCost < dist[to]) {
                    dist[to] = newCost;
                    q.add(new Node(to, dist[to]));
                }
            }
        }
        return dist;
    }

    static class Node implements Comparable<Node> {
        int index, cost;

        public Node(int i, int c) {
            index = i;
            cost = c;
        }

        @Override
        public int compareTo(Node o) {
            return new Integer(this.cost).compareTo(o.cost);
        }
    }

    static class Disj {
        int[] parent;

        public Disj(int n) {
            parent = new int[n];
            for (int i = 0; i < n; i++)
                parent[i] = i;
        }

        public int getParent(int i) {
            if (parent[i] == i)
                return i;
            else
                return parent[i] = getParent(parent[i]);
        }

        public boolean areSameSet(int i, int j) {
            return getParent(i) == getParent(j);
        }

        public void union(int i, int j) {
            parent[getParent(i)] = getParent(j);
        }

    }

    public static void main(String[] args) throws Exception {
        new Round234_D().solve();
    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer st;

        public InputReader() throws IOException {
            in = new BufferedReader(new InputStreamReader(System.in));
            st = new StringTokenizer(in.readLine());
        }

        public String next() throws IOException {

            while (!st.hasMoreElements())
                st = new StringTokenizer(in.readLine());
            return st.nextToken();
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }

}