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.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class ProblemD {
	
	static class Edge {
		int a;
		int b;
		int cost;
		
		Edge(int _a, int _b, int _c) {
			a = _a;
			b = _b;
			cost = _c;
		}
	}

	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = in.nextInt();
		int m = in.nextInt();
		int k = in.nextInt();
		int[] g = new int[n];
		int[][] range = new int[k][2];
		{
			int cidx = 0;
			for (int i = 0 ; i < k ; i++) {
				range[i][0] = cidx;
				int d = in.nextInt();
				for (int j = cidx ; j < cidx + d ; j++) {
					g[j] = i;
				}
				cidx += d;
				range[i][1] = cidx;
			}
		}

		Edge[] edges = new Edge[m];
		for (int i = 0 ; i < m ; i++) {
			edges[i] = new Edge(in.nextInt()-1, in.nextInt()-1, in.nextInt());
		}
		
		UnionFind uf = new UnionFind(n);
		for (int i = 0 ; i < m ; i++) {
			if (edges[i].cost == 0) {
				uf.unite(edges[i].a, edges[i].b);
			}
		}
		boolean isok = true;
		for (int i = 0 ; i < k ; i++) {
			for (int j = range[i][0] ; j < range[i][1] ; j++) {
				if (!uf.issame(range[i][0], j)) {
					isok = false;
					break;
				}
			}
		}
		if (!isok) {
			out.println("No");
			out.flush();
			return;
		}
		
		long[][] graph = new long[k][k];
		for (int i = 0 ; i < k ; i++) {
			Arrays.fill(graph[i], Integer.MAX_VALUE);
			graph[i][i] = 0;
 		}
		for (int i = 0 ; i < m ; i++) {
			int fr = g[edges[i].a];
			int to = g[edges[i].b];
			graph[fr][to] = Math.min(graph[fr][to], edges[i].cost);
			graph[to][fr] = Math.min(graph[to][fr], edges[i].cost);
		}
		
		
		for (int l = 0 ; l < k ; l++) {
			for (int i = 0 ; i < k ; i++) {
				for (int j = 0 ; j < k ; j++) {
					graph[i][j] = Math.min(graph[i][j], graph[i][l] + graph[l][j]);
				}
			}
		}
		
		out.println("Yes");
		for (int i = 0 ; i < k ; i++) {
			for (int j = 0 ; j < k ; j++) {
				if (j >= 1) {
					out.print(' ');
				}
				long ans = graph[i][j] >= Integer.MAX_VALUE ? -1 : graph[i][j];
				out.print(ans);
			}
			out.println();
		}
		out.flush();
	}

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

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

		public int next() {
			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 = next();
			while (isSpaceChar(c))
				c = next();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = next();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = next();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}

    static class UnionFind {
         int[] parent, rank;
         UnionFind(int n) {
              parent = new int[n];
              rank = new int[n];
              for (int i = 0 ; i < n ; i++) {
                   parent[i] = i;
                   rank[i] = 0;
              }
         }
        
         int find(int x) {
              if (parent[x] == x) {
                   return x;
              }
              parent[x] = find(parent[x]);
              return parent[x];
         }
        
         void unite(int x, int y) {
              x = find(x);
              y = find(y);
              if (x == y) {
                   return;
              }
              if (rank[x] < rank[y]) {
                   parent[x] = y;
              } else {
                   parent[y] = x;
                   if (rank[x] == rank[y]) {
                        rank[x]++;
                   }
              }
         }
         boolean issame(int x, int y) {
              return (find(x) == find(y));
         }
    }
}