#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int maxn = 999999999;
int d[510][510];
struct data {
  int from, to, v;
} l[100100];
int a[510], b[510];
int fa[100100];
int cmp(data p, data q) { return p.v < q.v; }
int find(int p) {
  if (fa[p] == p)
    return p;
  else
    return fa[p] = find(fa[p]);
}
int type[100100];
int vis[100100];
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d", &a[i]);
    b[i] = a[i];
  }
  for (int i = 1; i <= k; i++)
    for (int j = 1; j <= k; j++) {
      d[i][j] = maxn;
    }
  int top = 1;
  for (int i = 1; i <= n; i++) {
    fa[i] = i;
    while (a[top] == 0) top++;
    type[i] = top;
    a[top]--;
    while (a[top] == 0) top++;
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &l[i].from, &l[i].to, &l[i].v);
  }
  sort(l + 1, l + 1 + m, cmp);
  int bj = 1;
  for (int i = 1; i <= m; i++) {
    int pa = find(l[i].from);
    int pb = find(l[i].to);
    if (l[i].from == l[i].to && l[i].v != 0) bj = 0;
    if (pa != pb) {
      fa[pb] = pa;
      d[type[l[i].from]][type[l[i].to]] = d[type[l[i].to]][type[l[i].from]] =
          min(l[i].v, d[type[l[i].from]][type[l[i].to]]);
      if (type[l[i].from] == type[l[i].to]) {
        if (l[i].v != 0) bj = 0;
      }
      vis[l[i].from] = 1;
      vis[l[i].to] = 1;
    } else {
      d[type[l[i].from]][type[l[i].to]] = d[type[l[i].to]][type[l[i].from]] =
          min(l[i].v, d[type[l[i].from]][type[l[i].to]]);
    }
  }
  for (int i = 1; i <= k; i++) {
    if (d[i][i] == maxn) d[i][i] = 0;
  }
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= k; j++) {
      for (int l = 1; l <= k; l++) {
        if (d[j][l] > d[j][i] + d[i][l]) d[j][l] = d[j][i] + d[i][l];
      }
    }
  }
  for (int i = 1; i < n; i++) {
    if (type[i] == type[i + 1]) {
      if (find(i) != find(i + 1)) bj = 0;
    }
  }
  for (int i = 1; i <= k; i++)
    for (int j = 1; j <= k; j++) {
      if (d[i][j] == maxn) {
        d[i][j] = -1;
      }
      if (i == j && d[i][j] != 0) bj = 0;
    }
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0 && b[type[i]] > 1) bj = 0;
  }
  if (bj == 0)
    printf("No\n");
  else {
    printf("Yes\n");
    for (int i = 1; i <= k; i++)
      for (int j = 1; j <= k; j++) printf("%d%c", d[i][j], j == k ? '\n' : ' ');
  }
}
