#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 1, K = 501;
vector<long long> v[N];
long long vis[N], n, m, k, a, b, x, u1, v1, i, j, l;
long long c[K], p[K];
long long d[K][K];
tuple<long long, long long, long long> t[N];
void dfs(long long node) {
  vis[node] = 1;
  for (auto u : v[node]) {
    if (!vis[u]) dfs(u);
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m >> k;
  for (i = 1; i <= k; ++i) {
    cin >> c[i];
    p[i] += c[i] + p[i - 1];
  }
  for (i = 1; i <= m; ++i) {
    cin >> a >> b >> x;
    t[i] = make_tuple(a, b, x);
    if (!x) {
      v[a].push_back(b);
      v[b].push_back(a);
    }
  }
  for (i = 1; i <= k; ++i) {
    for (j = 1; j <= n; ++j) vis[j] = 0;
    dfs(p[i - 1] + 1);
    for (j = p[i - 1] + 1; j <= p[i]; ++j) {
      if (!vis[j]) break;
    }
    if (j <= p[i]) break;
  }
  if (i <= k) {
    cout << "No";
    return 0;
  } else {
    for (i = 1; i <= k; ++i) {
      for (j = 1; j <= k; ++j) {
        if (i != j) {
          d[i][j] = 1e10;
        }
      }
    }
    for (i = 1; i <= m; ++i) {
      a = get<0>(t[i]);
      b = get<1>(t[i]);
      x = get<2>(t[i]);
      u1 = lower_bound(p + 1, p + 1 + k, a) - p;
      v1 = lower_bound(p + 1, p + 1 + k, b) - p;
      if (u1 != v1) {
        d[u1][v1] = min(d[u1][v1], x);
        d[v1][u1] = min(d[v1][u1], x);
      }
    }
    for (i = 1; i <= k; ++i)
      for (j = 1; j <= k; ++j)
        for (l = 1; l <= k; ++l) {
          d[j][l] = min(d[j][l], d[j][i] + d[i][l]);
        }
    for (i = 1; i <= k; ++i) {
      for (j = 1; j <= k; ++j) {
        if (d[i][j] >= (1e10)) {
          d[i][j] = -1;
        }
      }
    }
    cout << "Yes\n";
    for (i = 1; i <= k; ++i) {
      for (j = 1; j <= k; ++j) {
        cout << d[i][j] << " ";
      }
      cout << "\n";
    }
  }
  return 0;
}
