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.*;
import java.util.*;

public final class DimaAndBacteria
{
    public static void main(String[] args)
    {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
		Solver solver = new Solver(in, out);

		solver.solve();
        in.close();
        out.flush();
        out.close();
    }

    static class Solver
    {
    	static int inf = (int) 1e9;
        int n, m, k;
        List<Edge>[] sameType, diffType, zeroWeight;
        int[] start, end, type, dist;
		boolean[] vis;
		int[][] minDist;
        InputReader in;
        PrintWriter out;

        void solve()
		{
			n = in.nextInt();
			m = in.nextInt();
			k = in.nextInt();
			sameType = new List[n];
			diffType = new List[n];
			zeroWeight = new List[n];
			start = new int[n];
			end = new int[n];
			type = new int[n];
			dist = new int[n];
			vis = new boolean[n];
			minDist = new int[k][k];

			int[] cnt = new int[k];
			int ctr = 0;

			for (int i = 0; i < k; i++)
			{
				cnt[i] = in.nextInt();
				start[i] = ctr;
				end[i] = start[i] + cnt[i] - 1;
				Arrays.fill(minDist[i], inf);

				int temp = cnt[i];

				while (temp-- > 0)
					type[ctr++] = i;
			}

			for (int i = 0; i < n; i++)
			{
				sameType[i] = new ArrayList<>();
				diffType[i] = new ArrayList<>();
				zeroWeight[i] = new ArrayList<>();
			}

			for (int i = 0; i < m; i++)
			{
				int u, v, wt;

				u = in.nextInt() - 1;
				v = in.nextInt() - 1;
				wt = in.nextInt();

				if (type[u] == type[v])
				{
					sameType[u].add(new Edge(u, v, wt > 0 ? 1 : 0));
					sameType[v].add(new Edge(v, u, wt > 0 ? 1 : 0));
				}
				else
				{
					diffType[u].add(new Edge(u, v, wt > 0 ? 1 : 0));
					diffType[v].add(new Edge(v, u, wt > 0 ? 1 : 0));
					minDist[type[u]][type[v]] = Math.min(minDist[type[u]][type[v]], wt);
					minDist[type[v]][type[u]] = Math.min(minDist[type[v]][type[u]], wt);
				}

				if (wt == 0)
				{
					zeroWeight[u].add(new Edge(u, v, 0));
					zeroWeight[v].add(new Edge(v, u, 0));
				}
			}

			for (int i = 0; i < k; i++)
				minDist[i][i] = 0;

/*			System.out.println("minDist :");

			for (int i = 0; i < k; i++, System.out.println())
				for (int j = 0; j < k; j++)
					System.out.print(minDist[i][j] + " ");*/

			boolean correct = true;

			for (int i = 0; i < k; i++)
			{
				zeroOneBFS(start[i]);

				for (int j = start[i]; j <= end[i]; j++)
				{
					if (dist[j] != 0)
					{
						correct = false;

						break;
					}
				}
			}

			if (!correct)
				out.println("No");
			else
			{
				out.println("Yes");
				floydWarshall(k);

				for (int i = 0; i < k; i++, out.println())
				{
					for (int j = 0; j < k; j++)
					{
						if (i == j)
							out.print(0 + " ");
						else if (minDist[i][j] == inf)
							out.print(-1 + " ");
						else
							out.print(minDist[i][j] + " ");
					}
				}
			}
		}

		void zeroOneBFS(int src)
		{
			Deque<Integer> deque = new LinkedList<>();
//			System.out.println("src : " + src);

			Arrays.fill(vis, false);
			Arrays.fill(dist, inf);
			dist[src] = 0;
			deque.add(src);

			while (deque.size() > 0)
			{
				int curr = deque.poll();

				vis[curr] = false;
//				System.out.println("curr : " + curr + ", dist[curr] : " + dist[curr]);

				for (Edge edge : zeroWeight[curr])
				{
					if (dist[curr] + edge.wt < dist[edge.to])
					{
						dist[edge.to] = dist[curr] + edge.wt;

						if (!vis[edge.to])
						{
							if (edge.wt == 0)
								deque.addFirst(edge.to);
							else
								deque.addLast(edge.to);

							vis[edge.to] = true;
						}
					}
				}
			}
		}

		void solve2()
		{
			n = in.nextInt();
			m = in.nextInt();
			k = in.nextInt();
			sameType = new List[n];
			diffType = new List[n];
			start = new int[n];
			end = new int[n];
			type = new int[n];
			dist = new int[n];
			minDist = new int[k][k];

			int[] cnt = new int[k];
			int ctr = 0;

			for (int i = 0; i < k; i++)
			{
				cnt[i] = in.nextInt();
				start[i] = ctr;
				end[i] = start[i] + cnt[i] - 1;
				Arrays.fill(minDist[i], inf);

				int temp = cnt[i];

				while (temp-- > 0)
					type[ctr++] = i;
			}

			for (int i = 0; i < n; i++)
			{
				sameType[i] = new ArrayList<>();
				diffType[i] = new ArrayList<>();
			}

			for (int i = 0; i < m; i++)
			{
				int u, v, wt;

				u = in.nextInt() - 1;
				v = in.nextInt() - 1;
				wt = in.nextInt();

				if (type[u] == type[v])
				{
					sameType[u].add(new Edge(u, v, wt));
					sameType[v].add(new Edge(v, u, wt));
				}
				else
				{
					diffType[u].add(new Edge(u, v, wt));
					diffType[v].add(new Edge(v, u, wt));
					minDist[type[u]][type[v]] = Math.min(minDist[type[u]][type[v]], wt);
					minDist[type[v]][type[u]] = Math.min(minDist[type[v]][type[u]], wt);
				}
			}

/*			System.out.println("minEdge :");

			for (int i = 0; i < k; i++, System.out.println())
				for (int j = 0; j < k; j++)
					System.out.print(minDist[i][j] + " ");*/

			boolean correct = true;

			for (int i = 0; i < k; i++)
			{
				dijkstra(cnt[i], start[i], sameType);
//				System.out.println("i : " + i + ", st[i] : " + start[i] + ", end[i] : " + end[i]);

				for (int j = start[i]; j <= end[i]; j++)
				{
					if (dist[j] != 0)
					{
						correct = false;
//						System.out.println("dist[" + j + "] : " + dist[j]);

						break;
					}
				}
			}

			if (!correct)
				out.println("No");
			else
			{
				out.println("Yes");
				floydWarshall(k);

				for (int i = 0; i < k; i++, out.println())
				{
					for (int j = 0; j < k; j++)
					{
						if (i == j)
							out.print(0 + " ");
						else if (minDist[i][j] == inf)
							out.print(-1 + " ");
						else
							out.print(minDist[i][j] + " ");
					}
				}
			}
		}

		void dijkstra(int v, int src, List<Edge>[] adj)
		{
			TreeSet<Integer> set = new TreeSet<>(new Comparator<Integer>()
			{
				@Override public int compare(Integer o1, Integer o2)
				{
					if (dist[o1] == dist[o2])
						return Integer.compare(o1, o2);

					return Integer.compare(dist[o1], dist[o2]);
				}
			});

			for (int i = src, j = 0; j < v; i++, j++)
				dist[i] = inf;

			dist[src] = 0;
			set.add(src);

			while (set.size() > 0)
			{
				int curr = set.pollFirst();

				for (Edge edge : adj[curr])
				{
					if (dist[curr] + edge.wt < dist[edge.to])
					{
						dist[edge.to] = dist[curr] + edge.wt;
						set.add(edge.to);
					}
				}
			}

			System.out.println("dist :");

			for (int i = src, j = 0; j < v; i++, j++)
				System.out.println(dist[i]);
		}

		void floydWarshall(int v)
		{
			for (int k = 0; k < v; k++)
			{
				for (int i = 0; i < v; i++)
				{
					for (int j = 0; j < v; j++)
					{
						if (minDist[i][k] + minDist[k][j] < minDist[i][j])
							minDist[i][j] = minDist[i][k] + minDist[k][j];
					}
				}
			}
		}

		class Edge
		{
			int fr, to, wt;

			public Edge(int fr, int to, int wt)
			{
				this.fr = fr;
				this.to = to;
				this.wt = wt;
			}

		}

        public Solver(InputReader in, PrintWriter out)
        {
        	this.in = in;
        	this.out = out;
        }

	}

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

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

        public int read()
        {
            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 = 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 & 15;

                c = read();
            } while (!isSpaceChar(c));

            return res * sgn;
        }

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

        public void close()
        {
            try
            {
                stream.close();
            } catch (IOException e)
            {
                e.printStackTrace();
            }
        }

    }

}