#include <bits/stdc++.h>
using namespace std;
long long i, u, v, r, n, k, m, x, d[100005], w[100005];
vector<long long> s[100005];
struct merge_segt {
  long long n, pos, v, ls[20 * 100005],
      tot = 0, rs[20 * 100005], mx[20 * 100005], tg[20 * 100005], hd[100005];
  void clr(int p) { ls[p] = rs[p] = mx[p] = tg[p] = 0; }
  void ins(long long &p, int l, int r) {
    int mid;
    p = ++tot;
    clr(p);
    mx[p] = v;
    if (l == r) return;
    mid = (l + r) / 2;
    if (pos <= mid)
      ins(ls[p], l, mid);
    else
      ins(rs[p], mid + 1, r);
  }
  void Create(int p, int pk, long long vw) {
    pos = pk;
    v = vw;
    ins(hd[p], 1, n);
  }
  void dow(int p, long long v) {
    mx[p] += v;
    tg[p] += v;
  }
  void push(int x) {
    if (tg[x] == 0) return;
    long long v = tg[x];
    if (ls[x]) dow(ls[x], v);
    if (rs[x]) dow(rs[x], v);
    tg[x] = 0;
  }
  void merge(long long &x, long long y, int l, int r, long long mxx,
             long long mxy) {
    int mid;
    long long vr;
    if (!x && !y) return;
    if (!x) {
      x = y;
      dow(x, mxx);
      return;
    }
    if (!y) {
      dow(x, mxy);
      return;
    }
    if (l == r) {
      mxy = max(mxy, mx[y]);
      mxx = max(mxx, mx[x]);
      vr = max(mxx + mx[y], mxy + mx[x]);
      mx[x] = vr;
      return;
    }
    push(x);
    push(y);
    mid = (l + r) / 2;
    merge(rs[x], rs[y], mid + 1, r, max(mxx, mx[ls[x]]), max(mxy, mx[ls[y]]));
    merge(ls[x], ls[y], l, mid, mxx, mxy);
    mx[x] = max(mx[ls[x]], mx[rs[x]]);
  }
  void merge2(long long &x, long long y, int l, int r, long long mxy) {
    int mid;
    if (!x && !y) return;
    if (!x) {
      x = y;
      return;
    }
    if (!y) {
      dow(x, mxy);
      return;
    }
    if (l == r) {
      mxy = max(mxy, mx[y]);
      dow(x, mxy);
      return;
    }
    mid = (l + r) / 2;
    push(x);
    push(y);
    merge2(rs[x], rs[y], mid + 1, r, max(mxy, mx[ls[y]]));
    merge2(ls[x], ls[y], l, mid, mxy);
    mx[x] = max(mx[ls[x]], mx[rs[x]]);
  }
} tr;
void dfs(int p) {
  int i, v;
  long long vp = 0;
  tr.Create(p, d[p], w[p]);
  for (i = 0; i < s[p].size(); i++) {
    v = s[p][i];
    dfs(v);
    if (vp == 0)
      vp = tr.hd[v];
    else
      tr.merge(vp, tr.hd[v], 1, k, 0LL, 0LL);
  }
  tr.merge2(tr.hd[p], vp, 1, k, 0LL);
}
int main() {
  scanf("%lld%lld%lld", &n, &m, &k);
  tr.n = k;
  for (i = 2; i <= n; i++) scanf("%lld", &x), s[x].push_back(i);
  for (i = 1; i <= m; i++) {
    scanf("%lld%lld%lld", &u, &v, &r);
    d[u] = v;
    w[u] = r;
  }
  for (i = 1; i <= n; i++)
    if (d[i] == 0) d[i] = 1;
  dfs(1);
  printf("%lld\n", tr.mx[tr.hd[1]]);
  return 0;
}
