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.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class DimaAndBacteria {

	static final int oo = 1 << 28;

	static class UnionFind {
		int[] rep, rank;

		UnionFind(int n) {
			rep = new int[n];
			rank = new int[n];
			for (int i = 0; i < n; i++)
				rep[i] = i;
		}

		int findSet(int x) {
			return rep[x] == x ? x : (rep[x] = findSet(rep[x]));
		}

		boolean sameSet(int x, int y) {
			return findSet(x) == findSet(y);
		}

		void union(int x, int y) {
			if (sameSet(x, y))
				return;
			x = findSet(x);
			y = findSet(y);
			if (rank[x] > rank[y])
				rep[y] = x;
			else {
				rep[x] = y;
				if (rank[x] == rank[y])
					rank[y]++;
			}
		}
	}

	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt(), m = sc.nextInt(), K = sc.nextInt();
		int[] c = new int[K + 1];
		for (int i = 1; i <= K; i++) {
			c[i] = sc.nextInt();
			if (i > 0)
				c[i] += c[i - 1];
		}
		UnionFind uf = new UnionFind(n + 1);
		int[] a = new int[m];
		int[] b = new int[m];
		int[] x = new int[m];
		for (int i = 0; i < m; i++) {
			int u = sc.nextInt(), v = sc.nextInt(), cost = sc.nextInt();
			if (cost == 0)
				uf.union(u, v);
			a[i] = u;
			b[i] = v;
			x[i] = cost;
		}
		boolean f = true;
		int[] type = new int[n + 1];
		for (int i = 1; i <= K && f; i++) {
			for (int j = c[i - 1] + 1; j + 1 <= c[i] && f; j++)
				if (!uf.sameSet(j, j + 1))
					f = false;
			for (int j = c[i - 1] + 1; j <= c[i]; j++)
				type[j] = i;
		}
		// System.err.println(Arrays.toString(type));
		if (!f) {
			out.println("No");
		} else {
			int[][] ans = new int[K + 1][K + 1];
			for (int i = 0; i <= K; i++) {
				Arrays.fill(ans[i], oo);
				ans[i][i] = 0;
			}
			for (int i = 0; i < m; i++) {
				int u = type[a[i]], v = type[b[i]];
				ans[u][v] = ans[v][u] = Math.min(ans[u][v], x[i]);
			}
			for (int k = 1; k <= K; k++)
				for (int i = 1; i <= K; i++)
					for (int j = 1; j <= K; j++)
						ans[i][j] = Math.min(ans[i][j], ans[i][k] + ans[k][j]);
			out.println("Yes");
			for (int i = 1; i <= K; i++)
				for (int j = 1; j <= K; j++) {
					out.print(ans[i][j] == oo ? -1 : ans[i][j]);
					if (j == K)
						out.println();
					else
						out.print(" ");
				}
		}
		out.flush();
		out.close();
	}

	static class MyScanner {

		BufferedReader br;
		StringTokenizer st;

		MyScanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
		}

		MyScanner(String filename) throws IOException {
			br = new BufferedReader(new FileReader(new File(filename)));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

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

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

		boolean ready() throws IOException {
			return br.ready();
		}
	}
}