#include <bits/stdc++.h>
using namespace std;
int source[555], c[555], mat[555][555];
int tot[100006], id[100006];
vector<vector<pair<int, int> > > adj;
bool vis[100006];
void dfs(int u) {
  vis[u] = 1;
  tot[id[u]]++;
  for (int j = 0; j < adj[u].size(); ++j) {
    pair<int, int> where = adj[u][j];
    if (where.second == 0 && !vis[where.first]) dfs(where.first);
  }
}
int main() {
  int n, m, k, a, b, w;
  cin >> n >> m >> k;
  int cont = 0;
  for (int i = 0; i < k; ++i) {
    source[i] = cont;
    scanf("%d", &c[i]);
    for (int p = cont; p < cont + c[i]; p++) id[p] = i;
    cont += c[i];
  }
  for (int i = 0; i < k; ++i)
    for (int j = 0; j < k; ++j) mat[i][j] = 1000000000;
  for (int i = 0; i < k; ++i) mat[i][i] = 0;
  adj.assign(n, vector<pair<int, int> >());
  for (int i = 0; i < m; ++i) {
    scanf("%d %d %d", &a, &b, &w);
    a--;
    b--;
    adj[a].push_back(pair<int, int>(b, w));
    adj[b].push_back(pair<int, int>(a, w));
    mat[id[a]][id[b]] = min(mat[id[a]][id[b]], w);
    mat[id[b]][id[a]] = min(mat[id[b]][id[a]], w);
  }
  for (int i = 0; i < k; ++i) {
    if (!vis[source[i]]) dfs(source[i]);
    if (tot[i] != c[i]) {
      puts("No");
      return 0;
    }
  }
  for (int current = 0; current < k; current++)
    for (int i = 0; i < k; ++i)
      for (int j = 0; j < k; ++j)
        mat[i][j] = min(mat[i][j], mat[i][current] + mat[current][j]);
  puts("Yes");
  for (int i = 0; i < k; ++i) {
    for (int j = 0; j < k; ++j)
      if (mat[i][j] >= 1000000000)
        cout << -1 << " ";
      else
        cout << mat[i][j] << " ";
    cout << endl;
  }
  return 0;
}
