Problem: Dima took up the biology of bacteria, as a result of his experiments, he invented k types of bacteria. Overall, there are n bacteria at his laboratory right now, and the number of bacteria of type i equals ci. For convenience, we will assume that all the bacteria are numbered from 1 to n. The bacteria of type ci are numbered from <image> to <image>.

With the help of special equipment Dima can move energy from some bacteria into some other one. Of course, the use of such equipment is not free. Dima knows m ways to move energy from some bacteria to another one. The way with number i can be described with integers ui, vi and xi mean that this way allows moving energy from bacteria with number ui to bacteria with number vi or vice versa for xi dollars.

Dima's Chef (Inna) calls the type-distribution correct if there is a way (may be non-direct) to move energy from any bacteria of the particular type to any other bacteria of the same type (between any two bacteria of the same type) for zero cost.

As for correct type-distribution the cost of moving the energy depends only on the types of bacteria help Inna to determine is the type-distribution correct? If it is, print the matrix d with size k × k. Cell d[i][j] of this matrix must be equal to the minimal possible cost of energy-moving from bacteria with type i to bacteria with type j.

Input

The first line contains three integers n, m, k (1 ≤ n ≤ 105; 0 ≤ m ≤ 105; 1 ≤ k ≤ 500). The next line contains k integers c1, c2, ..., ck (1 ≤ ci ≤ n). Each of the next m lines contains three integers ui, vi, xi (1 ≤ ui, vi ≤ 105; 0 ≤ xi ≤ 104). It is guaranteed that <image>.

Output

If Dima's type-distribution is correct, print string «Yes», and then k lines: in the i-th line print integers d[i][1], d[i][2], ..., d[i][k] (d[i][i] = 0). If there is no way to move energy from bacteria i to bacteria j appropriate d[i][j] must equal to -1. If the type-distribution isn't correct print «No».

Examples

Input

4 4 2
1 3
2 3 0
3 4 0
2 4 1
2 1 2


Output

Yes
0 2
2 0


Input

3 1 2
2 1
1 2 0


Output

Yes
0 -1
-1 0


Input

3 2 2
2 1
1 2 0
2 3 1


Output

Yes
0 1
1 0


Input

3 0 2
1 2


Output

No

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
long long n, m, k;
long long group[100005];
long long used[100005];
long long rused[100005];
long long best[500][500];
long long o;
vector<long long> gr;
vector<pair<long long, long long>> cons[100005];
set<pair<long long, long long>> gcons[100005];
void dfs(long long cur) {
  if (group[o] == group[cur]) {
    rused[cur] = 1;
  }
  used[cur] = 1;
  for (int x = 0; x < cons[cur].size(); x++) {
    if (used[cons[cur][x].first] == 2 && cons[cur][x].second == 0) {
      dfs(cons[cur][x].first);
    }
  }
}
int main() {
  cin >> n >> m >> k;
  long long p = 0;
  long long temp;
  long long cnt = 0;
  for (int x = 0; x < k; x++) {
    cin >> temp;
    gr.push_back(temp);
    while (temp > 0) {
      group[p] = cnt;
      p++;
      temp--;
    }
    cnt++;
  }
  for (int x = 0; x < n; x++) {
    used[x] = 2;
    rused[x] = 2;
  }
  long long one, two, three;
  for (int x = 0; x < m; x++) {
    cin >> one >> two >> three;
    cons[one - 1].push_back({two - 1, three});
    cons[two - 1].push_back({one - 1, three});
    auto it = gcons[group[one - 1]].lower_bound({group[two - 1], -1});
    if (group[one - 1] != group[two - 1]) {
      if (it != gcons[group[one - 1]].end()) {
        if (three < (*(it)).second && (*(it)).first == group[two - 1]) {
          gcons[group[one - 1]].erase(it);
          gcons[group[two - 1]].erase(
              gcons[group[two - 1]].lower_bound({group[one - 1], -1}));
          gcons[group[one - 1]].insert({group[two - 1], three});
          gcons[group[two - 1]].insert({group[one - 1], three});
        } else if ((*(it)).first != group[two - 1]) {
          gcons[group[one - 1]].insert({group[two - 1], three});
          gcons[group[two - 1]].insert({group[one - 1], three});
        }
      } else {
        gcons[group[one - 1]].insert({group[two - 1], three});
        gcons[group[two - 1]].insert({group[one - 1], three});
      }
    }
  }
  long long cur = 0;
  for (int x = 0; x < gr.size(); x++) {
    if (rused[cur] == 2) {
      for (int x = 0; x < n; x++) {
        used[x] = 2;
      }
      o = cur;
      dfs(cur);
      int p1 = cur;
      int p2 = cur;
      for (int y = cur; y < cur + gr[x]; y++) {
        if (rused[y] == 2) {
          cout << "No\n";
          return 0;
        }
      }
      cur += gr[x];
    }
  }
  cout << "Yes\n";
  for (int x = 0; x < gr.size(); x++) {
    long long used[gr.size()];
    long long bdt[gr.size()];
    for (int y = 0; y < gr.size(); y++) {
      bdt[y] = -1;
      used[y] = 2;
    }
    bdt[x] = 0;
    for (int y = 0; y < gr.size(); y++) {
      long long b = 100000000000000000;
      long long bi = -1;
      for (int z = 0; z < gr.size(); z++) {
        if (used[z] == 2 && bdt[z] != -1) {
          if (bdt[z] < b) {
            b = bdt[z];
            bi = z;
          }
        }
      }
      if (bi == -1) {
        break;
      }
      used[bi] = 1;
      for (auto con : gcons[bi]) {
        long long des = con.first;
        long long cost = con.second;
        if (bdt[des] == -1) {
          bdt[des] = cost + bdt[bi];
        } else {
          bdt[des] = min(bdt[des], cost + bdt[bi]);
        }
      }
    }
    for (int y = 0; y < gr.size(); y++) {
      best[x][y] = bdt[y];
      best[y][x] = bdt[y];
    }
  }
  for (int x = 0; x < gr.size(); x++) {
    for (int y = 0; y < gr.size(); y++) {
      cout << best[x][y] << " ";
    }
    cout << "\n";
  }
}