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:

// Imports
import java.util.*;
import java.io.*;

public class D400 {

    public static final int BIG = 700000000;
    public static List<CostPair>[] adj;
    
    public static int isEmpty(int[] arr) {
        for(int i = 0; i < arr.length; i++) {
            if(arr[i] == 0) {
                return i;
            }
        }
        return -1;
    }
    
    public static int[] djikstra(int n, int start) {
        // Visited set and distances
        Set<Integer> visited = new HashSet<>();
        int[] distance = new int[n];
        
        // Priority Queue to determine minimum for Djikstra's
        PriorityQueue<CostPair> pq = new PriorityQueue<>();
        
        // Add each vertex initially to the PriorityQueue and set distances to INF for non-start
        for(int i = 0; i < n; i++) {
            if(i != start) {
                distance[i] = BIG;
            }
            
            pq.add(new CostPair(i, distance[i]));
        }
        
        // For each, use greedy
        while(!pq.isEmpty() && visited.size() < n) {
            CostPair cp = pq.poll();
            
            visited.add(cp.first);
            for(int i = 0; i < adj[cp.first].size(); i++) {
                CostPair edge = adj[cp.first].get(i);
                distance[edge.first] = Math.min(distance[edge.first], 
                        distance[cp.first] + edge.cost);
                
                if(!visited.contains(edge.first)) {
                    pq.add(new CostPair(edge.first, distance[edge.first]));
                }
            }
        }
        
        // Return distance array
        return distance;
    }
    
    // Auxillary class for Djikstra
    static class CostPair implements Comparable {
        public int first;
        public int cost;
        public CostPair(int i, int cos) {
            first = i;
            cost = cos;
        }
        
        @Override
        public int compareTo(Object o) {
            if(o.getClass() == this.getClass()) {
                CostPair other = (CostPair) o;
                        
                if(this.cost < other.cost) {
                    return -1;
                }
                else if(this.cost > other.cost) {
                    return 1;
                }
                return 0;
            }
            return 0;
        }
    }
    
    /**
     * @param args the command line arguments
     * @throws IOException, FileNotFoundException 
     */
    public static void main(String[] args) throws IOException, FileNotFoundException {
        
        // TODO UNCOMMENT WHEN ALGORITHM CORRECT
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        
        /* BufferedReader f = new BufferedReader(new StringReader("4 4 2\n" +
"1 3\n" +
"2 3 0\n" +
"3 4 0\n" +
"2 4 1\n" +
"2 1 2")); */
        
        // TODO code application logic here
        StringTokenizer st = new StringTokenizer(f.readLine());
        int N = Integer.parseInt(st.nextToken());
        int M = Integer.parseInt(st.nextToken());
        int K = Integer.parseInt(st.nextToken());
        int[] count = new int[K];
        int[] group = new int[N];
        int[][] graph = new int[K][K];
        adj = new ArrayList[N];
        
        StringTokenizer counts = new StringTokenizer(f.readLine());
        for(int i = 0; i < K; i++) {
            count[i] = Integer.parseInt(counts.nextToken());
            for(int j = 0; j < K; j++) {
                graph[i][j] = BIG;
            }
        }
        
        int loc = 0;
        int sum = 0;
        for(int i = 0; i < N; i++) {
            adj[i] = new ArrayList<>();
            adj[i].add(new CostPair(i, 0));
            
            group[i] = loc;
            graph[group[i]][group[i]] = 0;
            if(i - sum + 1 == count[loc]) {
                // System.out.println(loc + " " + i + " " + sum);
                sum += count[loc];
                loc++;
            }
        }
        
        // System.out.println(Arrays.toString(group));
        
        for(int i = 0; i < M; i++) {
            StringTokenizer edge = new StringTokenizer(f.readLine());
            int a = Integer.parseInt(edge.nextToken()) - 1;
            int b = Integer.parseInt(edge.nextToken()) - 1;
            int c = Integer.parseInt(edge.nextToken());
            
            adj[a].add(new CostPair(b, c));
            adj[b].add(new CostPair(a, c));
            
            graph[group[a]][group[b]] = Math.min(c, graph[group[a]][group[b]]);
            graph[group[b]][group[a]] = Math.min(c, graph[group[b]][group[a]]);
        }
        
        // System.out.println(Arrays.deepToString(graph));
        int[] visited = new int[N];
        Queue<Integer> bfs = new ArrayDeque<Integer>();
        int ct = 1;
        int a = -2;
        while((a = isEmpty(visited)) != -1) {
            visited[a] = ct;
            bfs.add(a);
            while(!bfs.isEmpty()) {
                int b = bfs.poll();
                
                for(CostPair j : adj[b]) {
                    if(j.cost == 0 && visited[j.first] == 0) {
                        visited[j.first] = ct;
                        bfs.add(j.first);
                    }
                }
            }
            ct++;
        }
        
        int sgrp = visited[0];
        for(int i = 1; i < N; i++) {
            if(group[i] != group[i - 1]) {
                sgrp = visited[i];
            }
            
            if(visited[i] != sgrp) {
                System.out.println("No");
                System.exit(0);
            }
        }
        
        for(int l = 0; l < K; l++) {
            for(int i = 0; i < K; i++) {
                for(int j = 0; j < K; j++) {
                    if(graph[i][j] > graph[i][l] + graph[l][j]) {
                        graph[i][j] = graph[i][l] + graph[l][j];
                    }
                }
            }
        }
        
        System.out.println("Yes");
        for(int i = 0; i < K; i++) {
            StringBuilder sb = new StringBuilder();
            for(int j = 0; j < K; j++) {
                if(graph[i][j] == BIG) {
                    sb.append(-1);
                }
                else {
                    sb.append(graph[i][j]);
                }
                sb.append(" ");
            }
            System.out.println(sb.substring(0, sb.length() - 1));
        }
        
    }

}