#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 10;
int n, m, k;
int c[510];
int ss[510];
int ui[N], vi[N], xi[N];
int p[N];
int find(int x) { return x == p[x] ? x : p[x] = find(p[x]); }
int check() {
  for (int i = 1; i <= k; i++) {
    int fa = -1;
    for (int j = ss[i - 1] + 1; j <= ss[i]; j++) {
      int rt = find(j);
      if (fa == -1) fa = rt;
      if (rt != fa) return false;
    }
  }
  return true;
}
int mz[510][510];
int idx[N];
void solve() {
  puts("Yes");
  for (int i = 1; i <= k; i++) {
    for (int j = ss[i - 1] + 1; j <= ss[i]; j++) idx[j] = i;
  }
  memset(mz, -1, sizeof(mz));
  for (int i = 0; i < m; i++) {
    int u = idx[ui[i]];
    int v = idx[vi[i]];
    if (mz[u][v] == -1 || xi[i] < mz[u][v]) mz[u][v] = mz[v][u] = xi[i];
  }
  for (int i = 1; i <= k; i++) mz[i][i] = 0;
  for (int x = 1; x <= k; x++) {
    for (int i = 1; i <= k; i++)
      if (mz[i][x] != -1) {
        for (int j = 1; j <= k; j++)
          if (mz[x][j] != -1) {
            if (mz[i][j] == -1 || mz[i][j] > mz[i][x] + mz[x][j])
              mz[i][j] = mz[i][x] + mz[x][j];
          }
      }
  }
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= k; j++) printf("%d%c", mz[i][j], j == k ? '\n' : ' ');
  }
}
int main() {
  while (cin >> n >> m >> k) {
    int sm = 0;
    ss[0] = 0;
    for (int i = 1; i <= k; i++) {
      cin >> c[i];
      sm += c[i];
      ss[i] = sm;
    }
    for (int i = 0; i <= sm; i++) p[i] = i;
    for (int i = 0; i < m; i++) {
      cin >> ui[i] >> vi[i] >> xi[i];
      if (xi[i] == 0) {
        int u = find(ui[i]);
        int v = find(vi[i]);
        if (u != v) p[u] = v;
      }
    }
    if (check()) {
      solve();
    } else
      puts("No");
  }
  return 0;
}
