#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a[505];
struct edge {
  int to, nxt, v;
} e[200005];
int h[100005], tot;
int fa[100005];
int t[100005], dis[505][505];
void add_edge(int x, int y, int v) {
  e[++tot].to = y;
  e[tot].nxt = h[x];
  h[x] = tot;
}
int anc(int x) {
  int tx = x;
  while (tx != fa[tx]) tx = fa[tx];
  while (x != tx) {
    int tmp = x;
    x = fa[x];
    fa[tmp] = tx;
  }
  return x;
}
void comb(int x, int y) {
  x = anc(x), y = anc(y);
  if (x != y) fa[x] = y;
}
bool vis[100005];
void dfs(int x) {
  if (vis[x]) return;
  vis[x] = true;
  for (int i = h[x]; i; i = e[i].nxt) {
    dfs(e[i].to);
  }
}
int main() {
  memset(dis, 0x3f, sizeof dis);
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; ++i) fa[i] = i;
  for (int i = 1; i <= k; ++i) {
    scanf("%d", &a[i]);
    a[i] += a[i - 1];
    for (int j = a[i - 1] + 1; j <= a[i]; ++j) t[j] = i;
    dis[i][i] = 0;
  }
  for (int i = 1; i <= m; ++i) {
    int x, y, v;
    scanf("%d%d%d", &x, &y, &v);
    add_edge(x, y, v);
    add_edge(y, x, v);
    if (v == 0) comb(x, y);
    dis[t[y]][t[x]] = dis[t[x]][t[y]] = min(dis[t[x]][t[y]], v);
  }
  for (int i = 1; i <= k; ++i) {
    for (int j = a[i - 1] + 1; j < a[i]; ++j) {
      if (anc(j) != anc(a[i])) {
        printf("No\n");
        return 0;
      }
    }
  }
  printf("Yes\n");
  for (int l = 1; l <= k; ++l) {
    for (int i = 1; i <= k; ++i) {
      for (int j = 1; j <= k; ++j) {
        dis[i][j] = min(dis[i][j], dis[i][l] + dis[l][j]);
      }
    }
  }
  for (int i = 1; i <= k; ++i) {
    for (int j = 1; j <= k; ++j) {
      if (dis[i][j] == 0x3f3f3f3f)
        printf("-1 ");
      else
        printf("%d ", dis[i][j]);
    }
    printf("\n");
  }
  return 0;
}
