#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > adj[100005];
int adj2[505][505];
int t[505], v[100005];
int vis[100005];
bool bfs(int x, int y) {
  int qtd = 0;
  queue<int> q;
  q.push(x);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    if (vis[v] == x) continue;
    vis[v] = x;
    if (v >= x && v <= y) qtd++;
    for (int i = 0; i < adj[v].size(); i++) {
      if (!adj[v][i].second) q.push(adj[v][i].first);
    }
  }
  return qtd != (y - x + 1);
}
int main() {
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  memset(adj2, -1, sizeof adj2);
  for (int i = 0; i < k; i++) scanf("%d", t + i);
  for (int i = 0; i < m; i++) {
    int x, y, z;
    scanf("%d %d %d", &x, &y, &z);
    adj[x].push_back(make_pair(y, z));
    adj[y].push_back(make_pair(x, z));
  }
  int sum = 1;
  bool f = 0;
  for (int i = 0; i < k; i++) {
    f |= bfs(sum, sum + t[i] - 1);
    for (int j = sum; j < sum + t[i]; j++) v[j] = i;
    sum += t[i];
  }
  if (f) {
    printf("No\n");
    return 0;
  }
  printf("Yes\n");
  sum = 1;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < adj[i].size(); j++)
      if (adj2[v[i]][v[adj[i][j].first]] == -1 ||
          adj2[v[i]][v[adj[i][j].first]] > adj[i][j].second)
        adj2[v[i]][v[adj[i][j].first]] = adj[i][j].second;
  for (int l = 0; l < k; l++) {
    for (int j = 0; j < k; j++) {
      for (int i = 0; i < k; i++) {
        if (adj2[i][l] != -1 && adj2[l][j] != -1) {
          if (adj2[i][j] == -1 || adj2[i][l] + adj2[l][j] < adj2[i][j])
            adj2[i][j] = adj2[i][l] + adj2[l][j];
        }
      }
    }
  }
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < k; j++) {
      printf("%d ", i == j ? 0 : adj2[i][j]);
    }
    printf("\n");
  }
  return 0;
}
