#include <bits/stdc++.h>
using namespace std;
int type[100005], dis[100005], in[100005] = {0}, p[100005];
struct P {
  int v, c;
};
vector<P> s[100005];
vector<int> arr;
queue<int> que;
int fa(int k) {
  if (p[k] == k) return k;
  return p[k] = fa(p[k]);
}
void spfa(int st) {
  int i;
  memset(dis, -1, sizeof(dis));
  dis[st] = 0;
  que.push(st);
  in[st] = 1;
  while (que.size()) {
    int u = que.front();
    que.pop();
    in[u] = 0;
    for (i = 0; i < s[u].size(); i++) {
      P edge = s[u][i];
      if (dis[u] + edge.c < dis[edge.v] || dis[edge.v] == -1) {
        dis[edge.v] = dis[u] + edge.c;
        if (in[edge.v] == 0) {
          in[edge.v] = 1;
          que.push(edge.v);
        }
      }
    }
  }
}
int main() {
  int n, m, k, x, y, z, i, j, pre = 1, now = 0;
  scanf("%d%d%d", &n, &m, &k);
  arr.push_back(0);
  for (i = 1; i <= k; i++) {
    scanf("%d", &x);
    now += x;
    arr.push_back(now);
    for (j = pre; j <= now; j++) type[j] = i;
    pre = now + 1;
  }
  for (i = 1; i <= n; i++) p[i] = i;
  for (i = 0; i < m; i++) {
    scanf("%d%d%d", &x, &y, &z);
    if (z == 0) {
      int X = fa(x), Y = fa(y);
      if (X != Y) p[X] = Y;
    }
    x = type[x];
    y = type[y];
    s[x].push_back((P){y, z});
    s[y].push_back((P){x, z});
  }
  int flag = 1;
  for (i = 1; i <= k; i++) {
    int root = fa(arr[i - 1] + 1);
    for (j = arr[i - 1] + 1; j <= arr[i]; j++) {
      if (fa(j) != root) flag = 0;
    }
  }
  if (flag == 0) {
    puts("No");
    return 0;
  }
  puts("Yes");
  for (i = 1; i <= k; i++) {
    spfa(i);
    for (j = 1; j <= k; j++) {
      if (j > 1) putchar(' ');
      printf("%d", dis[j]);
    }
    puts("");
  }
}
