#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 100;
const long long MAXK = 1000 + 20;
long long tim[MAXN];
long long val[MAXN];
long long p[MAXN];
vector<long long> child[MAXN];
map<long long, long long> *dp[MAXN];
map<long long, long long> *merge(map<long long, long long> &a,
                                 map<long long, long long> &b) {
  if (b.size() > a.size()) swap(a, b);
  for (auto it : b) {
    if (a.count(it.first))
      a[it.first] += it.second;
    else
      a[it.first] = it.second;
  }
  return &a;
}
void dfs(long long i) {
  dp[i] = new map<long long, long long>();
  for (long long j : child[i]) {
    dfs(j);
    dp[i] = merge(*dp[i], *dp[j]);
  }
  long long suma = 0;
  map<long long, long long> &M = *dp[i];
  vector<pair<long long, long long>> s;
  auto it = M.upper_bound(tim[i]);
  while (it != M.end()) {
    s.push_back({it->first, it->second});
    suma += it->second;
    if (suma >= val[i]) break;
    it++;
  }
  if (suma <= val[i]) {
    for (auto i : s) M.erase(i.first);
  } else if (suma > val[i]) {
    for (long long t = 0; t + 1 < s.size(); t++) {
      M.erase(s[t].first);
    }
    M[s.back().first] = suma - val[i];
  }
  if (M.count(tim[i]) == 0) M[tim[i]] = 0;
  M[tim[i]] += val[i];
}
int main() {
  ios_base::sync_with_stdio(false);
  long long n, m, k;
  cin >> n >> m >> k;
  p[1] = 1;
  for (long long i = 2; i <= n; i++) {
    cin >> p[i];
    child[p[i]].push_back(i);
  }
  while (m--) {
    long long v, d, w;
    cin >> v >> d >> w;
    tim[v] = d;
    val[v] = w;
  }
  map<long long, long long> x;
  for (long long i = 1; i <= n; i++) x[tim[i]] = 0;
  x[k] = 0;
  long long timer = 0;
  for (auto &i : x) {
    i.second = timer++;
  }
  for (long long i = 1; i <= n; i++) tim[i] = x[tim[i]];
  dfs(1);
  long long suma = 0;
  for (auto it : (*dp[1])) suma += it.second;
  cout << suma << "\n";
}
