#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
const int INF = 0x3f3f3f3f;
struct edge {
  int x, y, w;
  edge(int _x = 0, int _y = 0, int _w = 0) {
    x = _x;
    y = _y;
    w = _w;
  }
  inline bool friend operator<(const edge &A, const edge &B) {
    return A.w < B.w;
  }
};
vector<edge> E;
int n, m, k;
int type[N];
int parent[N];
int c[N];
int ans[505][505];
int graf[505][505];
int find(int x) { return x == parent[x] ? x : parent[x] = find(parent[x]); }
inline void load() {
  scanf("%d %d %d", &n, &m, &k);
  int tip = 0;
  int cnt = 0;
  for (int i = 0; i < k; i++, tip++) {
    int x;
    scanf("%d", &c[i]);
    x = c[i];
    while (x--) type[cnt++] = tip;
  }
  for (int i = 0; i < m; i++) {
    int x, y, w;
    scanf("%d %d %d", &x, &y, &w);
    --x;
    --y;
    E.push_back(edge(x, y, w));
  }
}
inline void solve() {
  sort(E.begin(), E.end());
  for (int i = 0; i < n; i++) parent[i] = i;
  for (int i = 0; i < m; i++) {
    if (E[i].w == 0) {
      int x = E[i].x;
      int y = E[i].y;
      x = find(x);
      y = find(y);
      if (x != y) parent[x] = y;
    }
  }
  for (int i = 0; i < n; i++) parent[i] = find(i);
  int cnt = 0;
  for (int i = 0; i < k; i++) {
    int x = c[i];
    int koji = parent[cnt];
    bool ok = false;
    while (x--) {
      if (parent[cnt] != koji) ok = true;
      cnt++;
    }
    if (ok) {
      printf("No\n");
      return;
    }
  }
  printf("Yes\n");
  memset(graf, INF, sizeof(graf));
  for (int i = 0; i < k; i++) graf[i][i] = 0;
  for (int i = 0; i < n; i++) parent[i] = i;
  for (int i = 0; i < m; i++) {
    int x = E[i].x;
    int y = E[i].y;
    int w = E[i].w;
    x = type[x];
    y = type[y];
    if (x != y) {
      int e1 = x;
      int e2 = y;
      graf[e1][e2] = min(w, graf[e1][e2]);
      graf[e2][e1] = min(w, graf[e2][e1]);
    }
  }
  for (int f = 0; f < k; f++) {
    for (int i = 0; i < k; i++) {
      for (int j = 0; j < k; j++) {
        graf[i][j] = min(graf[i][j], graf[i][f] + graf[f][j]);
      }
    }
  }
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < k; j++) {
      printf("%d ", graf[i][j] == INF ? -1 : graf[i][j]);
    }
    printf("\n");
  }
}
int main(void) {
  load();
  solve();
  return 0;
}
