#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 100005;
const long long SQRTN = 1003;
const long long LOGN = 22;
const double PI = acos(-1);
const long long INF = 1e16;
const long long MOD = 1000000007;
const long long FMOD = 998244353;
const double eps = 1e-9;
void solvethetestcase();
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  for (long long testcase = 1; testcase < t + 1; testcase++) {
    solvethetestcase();
  }
}
long long n, m, k;
vector<long long> adj[MAXN];
long long par[MAXN], day[MAXN], val[MAXN], sz[MAXN];
long long ans;
map<long long, long long>* gg[MAXN];
void dfs(long long u) {
  long long bc = -1;
  sz[u] = 1;
  for (auto v : adj[u]) {
    dfs(v);
    if (bc == -1 or sz[v] > sz[bc]) bc = v;
    sz[u] += sz[v];
  }
  if (bc != -1)
    gg[u] = gg[bc];
  else
    gg[u] = new map<long long, long long>();
  for (auto v : adj[u]) {
    if (v != bc) {
      for (auto x : *gg[v]) {
        (*gg[u])[x.first] += x.second;
      }
    }
  }
  if (day[u] != -1) {
    (*gg[u])[day[u]] += val[u];
    long long sm = 0;
    while (true) {
      auto it = next(gg[u]->find(day[u]));
      if (it == gg[u]->end()) break;
      sm += it->second;
      gg[u]->erase(it->first);
      if (sm > val[u]) {
        (*gg[u])[it->first] = sm - val[u];
        break;
      }
    }
  }
}
void solvethetestcase() {
  cin >> n >> m >> k;
  for (long long i = 1; i < n + 1; i++) {
    day[i] = -1;
    if (i == 1) continue;
    cin >> par[i];
    adj[par[i]].push_back(i);
  }
  for (long long i = 0; i < m; i++) {
    long long v, d, w;
    cin >> v >> d >> w;
    day[v] = d;
    val[v] = w;
  }
  long long ans = 0;
  dfs(1);
  for (auto x : *gg[1]) ans += x.second;
  cout << ans << endl;
}
