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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
struct comp {
  bool operator()(const pair<int, int> &a, const pair<int, int> &b) {
    return a.second > b.second;
  }
};
vector<int> sum;
priority_queue<pair<int, int>, vector<pair<int, int> >, comp> Q;
vector<pair<int, int> > E[100010];
vector<bool> visited(100010, 0);
vector<int> dist(100010, 1000000010);
int mat[555][555];
bool vis[100010];
vector<int> adj[100010];
set<int> S;
int bs(int key) {
  int len = sum.size(), i, j;
  int l = 0, r = len - 1, ret;
  while (l <= r) {
    int mid = l + (r - l + 1) / 2;
    if (sum[mid] < key) {
      l = mid + 1;
    } else {
      ret = mid;
      r = mid - 1;
    }
  }
  return ret;
}
void dijkstra(int src, int end) {
  dist[src] = 0;
  Q.push(make_pair(src, 0));
  while (!Q.empty()) {
    int u = Q.top().first;
    Q.pop();
    if (visited[u] == 0) {
      int len = E[u].size();
      for (int i = 0; i < len; i++) {
        int v = E[u][i].first;
        int w = E[u][i].second;
        if (v >= src and v <= end) {
          if (dist[u] + w < dist[v] and visited[v] == 0) {
            dist[v] = dist[u] + w;
            Q.push(make_pair(v, dist[v]));
          }
        }
      }
      visited[u] = 1;
    }
  }
}
void dfs(int src) {
  int idx = bs(src);
  S.insert(idx);
  vis[src] = 1;
  int i, j, k, len = adj[src].size();
  for (i = 0; i < len; i++) {
    if (vis[adj[src][i]] == 0) {
      dfs(adj[src][i]);
    }
  }
}
int main() {
  int n, m, k, i, j;
  vector<int> vec;
  scanf("%d", &n);
  scanf("%d", &m);
  scanf("%d", &k);
  sum.push_back(0);
  memset(vis, 0, sizeof(vis));
  for (i = 1; i <= k; i++) {
    int temp;
    scanf("%d", &temp);
    sum.push_back(sum[i - 1] + temp);
  }
  while (m--) {
    int u, v, x;
    scanf("%d", &u);
    scanf("%d", &v);
    scanf("%d", &x);
    E[u].push_back(make_pair(v, x));
    E[v].push_back(make_pair(u, x));
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  bool yes = 1;
  for (i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      S.clear();
      dfs(i);
      set<int>::iterator it;
      for (it = S.begin(); it != S.end(); it++) {
        int u = *it;
        for (j = sum[u - 1] + 1; j <= sum[u]; j++) {
          if (vis[j] == 0) {
            yes = 0;
            cout << "No" << endl;
            return 0;
          }
        }
      }
    }
  }
  for (i = 1; i <= k; i++) {
    int start = sum[i - 1] + 1, end = sum[i];
    dijkstra(start, end);
    for (j = start + 1; j <= end; j++) {
      if (dist[j] != 0) {
        vec.push_back(i);
        break;
      }
    }
  }
  for (i = 1; i <= k; i++) {
    for (j = 1; j <= k; j++) {
      if (i == j)
        mat[i][j] = 0;
      else
        mat[i][j] = 1000000010;
    }
  }
  for (i = 1; i <= n; i++) {
    int len = E[i].size();
    int idx1 = bs(i);
    for (j = 0; j < len; j++) {
      int v = E[i][j].first;
      int w = E[i][j].second;
      int idx2 = bs(v);
      if (idx1 != idx2) {
        mat[idx1][idx2] = min(mat[idx1][idx2], w);
      }
    }
  }
  for (int kk = 1; kk <= k; kk++) {
    for (i = 1; i <= k; i++) {
      for (j = 1; j <= k; j++) {
        mat[i][j] = min(mat[i][j], mat[i][kk] + mat[kk][j]);
      }
    }
  }
  int len = vec.size();
  for (i = 0; i < len; i++) {
    int u = vec[i];
    bool flag = 0;
    for (j = 1; j <= k; j++) {
      if (u != j) {
        if (mat[u][j] == 0) {
          flag = 1;
          break;
        }
      }
    }
    if (flag == 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  printf("Yes\n");
  for (i = 1; i <= k; i++) {
    for (j = 1; j <= k; j++) {
      if (mat[i][j] == 1000000010)
        printf("-1 ");
      else
        printf("%d ", mat[i][j]);
    }
    printf("\n");
  }
  return 0;
}