#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int ran[509];
int mark[100009];
int type[509];
bool ok = true;
vector<vector<int> > a, b;
int d[509][509];
struct node {
  int index;
  int value;
  node(int a, int b) {
    index = a;
    value = b;
  }
};
bool operator<(struct node a, struct node b) { return a.value > b.value; }
bool vis[100009];
int value[100009];
int st[509];
int en[509];
void check(int x, int source) {
  int i;
  source = mark[source];
  for (i = st[x]; i <= en[x]; i++) {
    if (value[i] != value[st[x]]) {
      ok = false;
    }
  }
  d[x][x] = 0;
  d[source][x] = d[x][source] = value[st[x]];
}
void ff(int source) {
  int i;
  set<int> st;
  priority_queue<struct node> p;
  p.push(node(source, 0));
  while (p.size()) {
    struct node s = p.top();
    p.pop();
    if (vis[s.index]) continue;
    st.insert(mark[s.index]);
    type[mark[s.index]]++;
    vis[s.index] = true;
    value[s.index] = s.value;
    int x = s.index;
    for (i = (0); i < (a[x].size()); ++i) {
      int y = a[x][i];
      if (vis[y]) continue;
      p.push(node(y, s.value + b[x][i]));
    }
  }
  set<int>::iterator it;
  for (it = st.begin(); it != st.end(); it++) {
    int x = (*it);
    if (type[x] != ran[x]) {
      ok = false;
      return;
    }
    check(x, source);
  }
}
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  scanf("%d", &k);
  int i, j;
  for (i = (0); i < (k); ++i) scanf("%d", &ran[i]);
  j = 0;
  for (i = (0); i < (k); ++i) {
    int last = j + ran[i];
    st[i] = j;
    while (j != last) {
      mark[j] = i;
      en[i] = j;
      j++;
    }
  }
  a.resize(n);
  b.resize(n);
  while (m--) {
    int x, y, z;
    scanf("%d", &x);
    scanf("%d", &y);
    scanf("%d", &z);
    x--;
    y--;
    a[x].push_back(y);
    a[y].push_back(x);
    b[x].push_back(z);
    b[y].push_back(z);
  }
  for (i = (0); i < (n); ++i) {
    vis[i] = false;
    value[i] = 1000000000;
  }
  for (i = (0); i < (n); ++i) {
    if (vis[i]) continue;
    ff(i);
    if (!ok) {
      printf("No\n");
      return 0;
    }
  }
  cout << "Yes" << endl;
  for (i = (0); i < (k); ++i) {
    for (j = (0); j < (k); ++j) d[i][j] = 1000000000;
    d[i][i] = 0;
  }
  for (i = (0); i < (n); ++i) {
    for (j = (0); j < (a[i].size()); ++j) {
      int x = a[i][j];
      if (mark[i] == mark[x]) continue;
      d[mark[i]][mark[x]] = min(d[mark[i]][mark[x]], b[i][j]);
    }
  }
  int kk;
  for (kk = (0); kk < (k); ++kk)
    for (i = (0); i < (k); ++i)
      for (j = (0); j < (k); ++j) d[i][j] = min(d[i][j], d[i][kk] + d[kk][j]);
  for (i = (0); i < (k); ++i) {
    for (j = (0); j < (k); ++j) {
      if (d[i][j] == 1000000000) d[i][j] = -1;
      cout << d[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
