#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template <class T>
inline bool ckmin(T& a, T b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
inline bool ckmax(T& a, T b) {
  return b > a ? a = b, 1 : 0;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const char nl = '\n';
const int mxN = 1e5 + 10;
const int MOD = 1e9 + 7;
const long long infLL = 1e18;
template <class T, class U>
std::ostream& operator<<(ostream& second, const pair<T, U>& x) {
  return second << "( " << x.first << ", " << x.second << ")";
}
template <class T>
void stlts(T V) {
  cout << "[";
  bool first = 1;
  for (auto& x : V) {
    if (first)
      cout << x, first = 0;
    else {
      cout << ", " << x;
    }
  }
  cout << "]" << endl;
}
int n, m, k, p[mxN];
pair<ll, ll> first[mxN];
map<int, ll> dp[mxN];
ll res = 0;
void upd(map<int, ll>& c, ll d, ll w) {
  c[d] += w;
  auto it = c.find(d);
  it++;
  for (; it != c.end() && w != 0;) {
    int mn = min(w, it->second);
    w -= mn;
    it->second -= mn;
    if (it->second == 0) {
      c.erase(it++);
    } else {
      break;
    }
  }
}
void comb(map<int, ll>& x, map<int, ll>& y) {
  if ((int)x.size() < (int)y.size()) swap(x, y);
  for (auto& v : y) {
    x[v.first] += v.second;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> k;
  for (int i = (2); i < (n + 1); i++) {
    cin >> p[i];
  }
  for (int i = (0); i < (m); i++) {
    int x, y, z;
    cin >> x >> y >> z;
    first[x] = {y, z};
  }
  for (int i = (n + 1 - 1); i >= (2); i--) {
    if (first[i].first) upd(dp[i], first[i].first, first[i].second);
    comb(dp[p[i]], dp[i]);
  }
  for (auto& v : dp[1]) {
    res += v.second;
  }
  cout << res << nl;
  return 0;
}
