#include <bits/stdc++.h>
using namespace std;
int const MAX_N = 100005;
int const MAX_M = 100005;
int const MAX_K = 507;
int const INF = 0x3F3F3F3F;
int const NA = -1;
int d[MAX_N];
int e[MAX_N];
int u[MAX_M];
int v[MAX_M];
int w[MAX_M];
int c[MAX_K];
int a[MAX_K][MAX_K];
int up(int p) {
  if (e[p] == p) {
    return p;
  }
  return (e[p] = up(e[p]));
}
void unite(int p, int q) {
  p = up(p);
  q = up(q);
  if (p != q) {
    e[p] = q;
  }
}
int main(void) {
  int n, m, k;
  while (scanf(" %d %d %d", &n, &m, &k) != EOF) {
    int p = 0;
    for (int i = 0; i < k; i++) {
      scanf(" %d", &c[i]);
      for (int j = 0; j < c[i]; j++) {
        d[p] = i;
        p++;
      }
    }
    for (int i = 0; i < n; i++) {
      e[i] = i;
    }
    for (int j = 0; j < m; j++) {
      scanf(" %d %d %d", &u[j], &v[j], &w[j]);
      u[j]--;
      v[j]--;
      if (w[j] == 0) {
        unite(u[j], v[j]);
      }
    }
    bool ok = true;
    for (int i = 1; i < n; i++) {
      if ((d[i - 1] == d[i]) && (up(e[i - 1]) != up(e[i]))) {
        ok = false;
      }
    }
    if (!ok) {
      printf("No\n");
      continue;
    }
    printf("Yes\n");
    for (int i = 0; i < k; i++) {
      for (int j = 0; j < k; j++) {
        a[i][j] = INF * (i != j);
      }
    }
    for (int j = 0; j < m; j++) {
      a[d[u[j]]][d[v[j]]] = min(a[d[u[j]]][d[v[j]]], w[j]);
      a[d[v[j]]][d[u[j]]] = min(a[d[v[j]]][d[u[j]]], w[j]);
    }
    for (int l = 0; l < k; l++) {
      for (int i = 0; i < k; i++) {
        for (int j = 0; j < k; j++) {
          a[i][j] = min(a[i][j], a[i][l] + a[l][j]);
        }
      }
    }
    for (int i = 0; i < k; i++) {
      for (int j = 0; j < k; j++) {
        printf("%d%c", (a[i][j] < INF) ? a[i][j] : NA, "\n "[j + 1 < k]);
      }
    }
  }
  return 0;
}
