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:
/**
 * DA-IICT
 * Author : PARTH PATEL
 */
import java.io.*;
import java.math.*;
import java.util.*;

import static java.util.Arrays.fill;
import static java.lang.Math.*;
import static java.util.Arrays.sort;
import static java.util.Collections.sort;


public class D400 {

	public static int mod = 1000000007;
	static FasterScanner in = new FasterScanner();
	static PrintWriter out = new PrintWriter(System.out);
	static int n,m,k;
	static int[] type;
	static int[] parent;
	static int[] size;
	static int[][] distance;
	public static void initialize()
	{
		for(int i=1;i<=n;i++)
		{
			parent[i]=i;
			size[i]=1;
		}
		for(int i=1;i<=k;i++)
		{
			for(int j=1;j<=k;j++)
				{
				distance[i][j]=Integer.MAX_VALUE/2;
				}
		}
	}
	public static int findheadof(int x)
	{
		while(parent[x]!=x)
		{
			parent[x]=parent[parent[x]];
			x=parent[x];
		}
		return x;
	}
	public static void union(int x,int y)
	{
		int a=findheadof(x);
		int b=findheadof(y);
		if(a==b)
			return;
		if(size[a]>=size[b])
		{
			parent[b]=a;
			size[a]+=size[b];
		}
		else
		{
			parent[a]=b;
			size[b]+=size[a];
		}
	}
	public static void main(String[] args) {

		n=in.nextInt();
		m=in.nextInt();
		k=in.nextInt();
		type=new int[n+1];
		parent=new int[n+1];
		size=new int[n+1];
		distance=new int[k+1][k+1];
		int count=1;
		ArrayList<Integer> list=new ArrayList<>();
		for(int i=1;i<=k;i++)
		{
			int c=in.nextInt();
			list.add(count);
			for(int j=1;j<=c;j++)
			{
				type[count++]=i;
			}
		}
		/*for(int i=1;i<=n;i++)
			out.print(type[i]+" ");
			*/
		initialize();
		for(int i=1;i<=m;i++)
		{
			int u=in.nextInt();
			int v=in.nextInt();
			int w=in.nextInt();
				if(w==0)
				union(u, v);
				
			distance[type[u]][type[v]]=min(distance[type[u]][type[v]], w);
			distance[type[v]][type[u]]=min(distance[type[v]][type[u]], w);
			
		}
		for(int l=1;l<=k;l++)
		{
			for(int i=1;i<=k;i++)
			{
				for(int j=1;j<=k;j++)
				{
					distance[i][j]=min(distance[i][j], distance[i][l]+distance[l][j]);
					distance[j][i]=distance[i][j];
				}
			}
		}
		boolean isyes=true;
		for(int i=1;i<=n;i++)
		{
			if(findheadof(i)==findheadof(list.get(type[i]-1)))
				continue;
			else
			{
				isyes=false;
				break;
			}
		}
		if(isyes)
		{
			out.println("Yes");
			for(int i=1;i<=k;i++)
			{
				for(int j=1;j<=k;j++)
				{
					if(i==j)
						{
						out.print("0 ");
						continue;
						}
					if(distance[i][j]==Integer.MAX_VALUE/2)
					{
						out.print("-1 ");
						continue;
					}
					out.print(distance[i][j]+" ");
				}
				out.println();
			}
		}
		else
		{
			out.println("No");
		}
		out.close();

	}

	public static long pow(long x, long n, long mod) {
		long res = 1;
		for (long p = x; n > 0; n >>= 1, p = (p * p) % mod) {
			if ((n & 1) != 0) {
				res = (res * p % mod);
			}
		}
		return res;
	}

	public static long gcd(long n1, long n2) {
		long r;
		while (n2 != 0) {
			r = n1 % n2;
			n1 = n2;
			n2 = r;
		}
		return n1;
	}

	public static long lcm(long n1, long n2) {
		long answer = (n1 * n2) / (gcd(n1, n2));
		return answer;
	}

	static class FasterScanner {
		private byte[] buf = new byte[1024];
		private int curChar;
		private int snumChars;

		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = System.in.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public String nextString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

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

		public int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

		public long[] nextLongArray(int n) {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLong();
			}
			return arr;
		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}
	}

}