#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
const int maxb = 501;
int mp[maxb][maxb];
int belong[maxn], par[maxn];
int findset(int x) {
  if (par[x] != x) par[x] = findset(par[x]);
  return par[x];
}
void unionset(int x, int y) {
  int fx = findset(x);
  int fy = findset(y);
  par[fx] = fy;
}
int sum;
void solve(int n) {
  for (int i = 2; i <= sum; i++) {
    if (belong[i] == belong[i - 1] && findset(i) != findset(i - 1)) {
      puts("No");
      return;
    }
  }
  puts("Yes");
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      if (mp[i][k] == -1) continue;
      for (int j = 1; j <= n; j++)
        if (mp[k][j] != -1) {
          if (mp[i][j] == -1 || mp[i][j] > mp[i][k] + mp[k][j])
            mp[i][j] = mp[i][k] + mp[k][j];
        }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) printf("%d%c", mp[i][j], j == n ? '\n' : ' ');
  }
}
int main() {
  memset(mp, -1, sizeof(mp));
  int a, b, c;
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  int pre = 0;
  sum = 0;
  for (int i = 1; i <= k; i++) {
    mp[i][i] = 0;
    scanf("%d", &a);
    sum += a;
    for (int j = pre + 1; j <= sum; j++) belong[j] = i;
    pre = sum;
  }
  for (int i = 1; i <= sum; i++) par[i] = i;
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &a, &b, &c);
    if (belong[a] == belong[b]) {
      if (!c) unionset(a, b);
    } else {
      if (!c) unionset(a, b);
      a = belong[a];
      b = belong[b];
      if (mp[a][b] == -1 || mp[a][b] > c) mp[a][b] = mp[b][a] = c;
    }
  }
  solve(k);
}
