#include <bits/stdc++.h>
using namespace std;
struct fr {
  int v, d;
  long long w;
};
void answ(long long r) {
  cout << r << "\n";
  exit(0);
}
int n, m, k;
std::vector<std::vector<int> > e;
std::vector<int> inv;
std::vector<fr> f;
void rek7(int a, std::map<int, long long> &mkw) {
  mkw[0] = 0;
  int es = (int)e[a].size();
  std::vector<std::map<int, long long> > mkwc(es);
  for (int i = 0; i < es; i++) {
    rek7(e[a][i], mkwc[i]);
    if (mkwc[i].size() > mkw.size()) mkw.swap(mkwc[i]);
  }
  for (auto m : mkwc)
    for (auto x : m) mkw[x.first] += x.second;
  if (inv[a] != -1) {
    mkw[f[inv[a]].d] += f[inv[a]].w;
    auto it = mkw.upper_bound(f[inv[a]].d);
    long long t = f[inv[a]].w;
    while (it != mkw.end() && it->second <= t) {
      t -= it->second;
      mkw.erase(it->first);
      it = mkw.upper_bound(f[inv[a]].d);
    }
    if (it != mkw.end()) it->second -= t;
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> k;
  e.resize(n);
  f.resize(m);
  inv.resize(n, -1);
  for (int i = 1; i < n; i++) {
    int t;
    cin >> t;
    t--;
    e[t].push_back(i);
  }
  for (int i = 0; i < m; i++) {
    cin >> f[i].v >> f[i].d >> f[i].w;
    f[i].v--;
    f[i].d--;
    inv[f[i].v] = i;
  }
  std::map<int, long long> mkw;
  rek7(0, mkw);
  long long r = 0;
  for (auto x : mkw) r += x.second;
  answ(r);
}
