#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int pre[N];
int find(int x) {
  if (!pre[x]) return x;
  return pre[x] = find(pre[x]);
}
int d[510][510];
struct point {
  int x, y, z;
  void read() { scanf("%d%d%d", &x, &y, &z); }
} a[N];
int type[N];
int main() {
  int n, m, r, x, y;
  scanf("%d%d%d", &n, &m, &r);
  int t = 0;
  for (int i = 1; i <= r; i++) {
    scanf("%d", &x);
    while (x--) type[++t] = i;
  }
  for (int i = 1; i <= m; i++) {
    a[i].read();
    if (a[i].z == 0) {
      x = find(a[i].x);
      y = find(a[i].y);
      if (x != y) pre[x] = y;
    }
  }
  for (int i = 2; i <= n; i++)
    if (type[i] == type[i - 1] && find(i) != find(i - 1)) {
      cout << "No" << endl;
      return 0;
    }
  memset(d, -1, sizeof(d));
  for (int i = 1; i <= m; i++) {
    x = type[a[i].x], y = type[a[i].y];
    if (d[x][y] == -1)
      d[y][x] = d[x][y] = a[i].z;
    else
      d[y][x] = d[x][y] = min(d[x][y], a[i].z);
  }
  for (int i = 1; i <= r; i++) d[i][i] = 0;
  for (int k = 1; k <= r; k++)
    for (int i = 1; i <= r; i++)
      for (int j = 1; j <= r; j++)
        if (d[i][k] != -1 && d[k][j] != -1)
          if (d[i][j] == -1)
            d[i][j] = d[i][k] + d[k][j];
          else
            d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  cout << "Yes" << endl;
  for (int i = 1; i <= r; i++) {
    for (int j = 1; j <= r; j++) {
      printf("%d ", d[i][j]);
    }
    printf("\n");
  }
  return 0;
}
