Problem: We have a magic tree: a rooted tree on n vertices. The vertices are numbered 1 through n. Vertex 1 is the root.

The magic tree gives us magic fruit. The fruit only grows in vertices of the tree other than the root. Each vertex contains at most one piece of fruit.

It is now day 0 and no fruit is ripe yet. Each fruit will only be ripe for a single day. For each fruit, we are given the vertex v_j where it grows, the day d_j on which it will be ripe, and the amount w_j of magic juice we can extract from it if we harvest it when it is ripe.

The fruits have to be harvested by cutting some branches of the tree. On each day, you may cut as many branches of the tree as you like. The parts of the tree you cut off will fall to the ground and you can collect all the ripe fruits they contain. All fruits that fall to the ground when they are not ripe are discarded and no magic juice is collected from them.

Formally, on each day, you may erase some edges of the tree. Whenever you do so, the tree will split into multiple connected components. You then erase all components that do not contain the root and you harvest all ripe fruits those components contained.

Given is a description of the tree together with the locations, ripening days and juiciness of all m fruits. Calculate the maximum total amount of magic juice we can harvest from the tree.

Input

The first line contains three space-separated integers n (2 ≤ n ≤ 100,000), m (1 ≤ m ≤ n-1) and k (1 ≤ k ≤ 100,000) – the number of vertices, the number of fruits, and the maximum day on which a fruit may become ripe.

The following n-1 lines contain the integers p_2, ..., p_n, one per line. For each i (from 2 to n, inclusive), vertex p_i (1 ≤ p_i ≤ i-1) is the parent of vertex i.

Each of the last m lines describes one fruit. The j-th of these lines has the form "v_j\ d_j\ w_j" (2 ≤ v_j ≤ n, 1 ≤ d_j ≤ k, 1 ≤ w_j ≤ 10^9).

It is guaranteed that no vertex contains more than one fruit (i.e., the values v_j are distinct).

Output

Output a single line with a single integer, the maximum amount of magic juice we can harvest from the tree.

Scoring

Subtask 1 (6 points): n, k ≤ 20, and w_j = 1 for all j

Subtask 2 (3 points): fruits only grow in the leaves of the tree

Subtask 3 (11 points): p_i = i-1 for each i, and w_j = 1 for all j

Subtask 4 (12 points): k ≤ 2

Subtask 5 (16 points): k ≤ 20, and w_j = 1 for all j

Subtask 6 (13 points): m ≤ 1,000

Subtask 7 (22 points): w_j = 1 for all j

Subtask 8 (17 points): no additional constraints

Example

Input


6 4 10
1
2
1
4
4
3 4 5
4 7 2
5 4 1
6 9 3


Output


9

Note

In the example input, one optimal solution looks as follows: 

  * On day 4, cut the edge between vertices 4 and 5 and harvest a ripe fruit with 1 unit of magic juice. On the same day, cut the edge between vertices 1 and 2 and harvest 5 units of magic juice from the ripe fruit in vertex 3. 
  * On day 7, do nothing. (We could harvest the fruit in vertex 4 that just became ripe, but doing so is not optimal.) 
  * On day 9, cut the edge between vertices 1 and 4. Discard the fruit in vertex 4 that is no longer ripe, and harvest 3 units of magic juice from the ripe fruit in vertex 6. (Alternately, we could achieve the same effect by cutting the edge between vertices 4 and 6.) 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
ostream &operator<<(ostream &out, string str) {
  for (char c : str) out << c;
  return out;
}
template <class L, class R>
ostream &operator<<(ostream &out, pair<L, R> p) {
  return out << "(" << p.first << ", " << p.second << ")";
}
template <class T>
auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
  out << "{";
  for (auto it = a.begin(); it != a.end(); it = next(it))
    out << (it != a.begin() ? ", " : "") << *it;
  return out << "}";
}
void dump() { cerr << "\n"; }
template <class T, class... Ts>
void dump(T a, Ts... x) {
  cerr << a << ", ";
  dump(x...);
}
template <class T>
int size(T &&a) {
  return a.size();
}
using LL = long long;
using PII = pair<int, int>;
struct HLD {
  vector<vector<int>> graph;
  vector<int> size, pre, pos, nxt, par;
  int t = 0;
  void init(int v, int p = -1) {
    par[v] = p;
    size[v] = 1;
    for (int &u : graph[v])
      if (u != par[v]) {
        init(u, v);
        size[v] += size[u];
        if (size[u] > size[graph[v][0]]) swap(u, graph[v][0]);
      }
  }
  void set_paths(int v) {
    pre[v] = t++;
    for (int &u : graph[v])
      if (u != par[v]) {
        nxt[u] = (u == graph[v][0] ? nxt[v] : u);
        set_paths(u);
      }
    pos[v] = t;
  }
  HLD(int n, vector<vector<int>> graph, int root = 0)
      : graph(graph), size(n), pre(n), pos(n), nxt(n), par(n) {
    init(root);
    set_paths(root);
  }
  int lca(int v, int u) {
    while (nxt[v] != nxt[u]) {
      if (pre[v] < pre[u]) swap(v, u);
      v = par[nxt[v]];
    }
    return (pre[v] < pre[u] ? v : u);
  }
  vector<pair<int, int>> path_up(int v, int u) {
    vector<pair<int, int>> ret;
    while (nxt[v] != nxt[u]) {
      ret.emplace_back(pre[nxt[v]], pre[v]);
      v = par[nxt[v]];
    }
    ret.emplace_back(pre[u], pre[v]);
    return ret;
  }
  int get_vertex(int v) { return pre[v]; }
  vector<pair<int, int>> get_path(int v, int u, bool add_lca = true) {
    int w = lca(v, u);
    auto ret = path_up(v, w);
    auto path_u = path_up(u, w);
    if (add_lca) ret.emplace_back(pre[w], pre[w]);
    while (!path_u.empty()) {
      ret.emplace_back(path_u.back());
      path_u.pop_back();
    }
    return ret;
  }
  pair<int, int> get_subtree(int v) { return {pre[v], pos[v] - 1}; }
};
struct MaxTree {
  using T = PII;
  T f(T a, T b) { return max(a, b); }
  vector<T> nodes;
  int size = 1;
  MaxTree(int n, T val) {
    while (size < n) size *= 2;
    nodes.resize(size * 2, val);
  }
  void update(int pos, T val) {
    nodes[pos += size] = val;
    while (pos /= 2) nodes[pos] = f(nodes[pos * 2], nodes[pos * 2 + 1]);
  }
  T query(int l, int r) {
    l += size, r += size;
    T ret = (l != r ? f(nodes[l], nodes[r]) : nodes[l]);
    while (l + 1 < r) {
      if (l % 2 == 0) ret = f(ret, nodes[l + 1]);
      if (r % 2 == 1) ret = f(ret, nodes[r - 1]);
      l /= 2, r /= 2;
    }
    return ret;
  }
};
struct SumTree {
  using T = LL;
  T f(T a, T b) { return a + b; }
  vector<T> nodes;
  int size = 1;
  SumTree(int n, T val = 0) {
    while (size < n) size *= 2;
    nodes.resize(size * 2, val);
  }
  T query(int pos) {
    T ret = nodes[pos += size];
    while (pos /= 2) ret = f(ret, nodes[pos]);
    return ret;
  }
  T query(int l, int r) {
    l += size, r += size;
    T ret = (l != r ? f(nodes[l], nodes[r]) : nodes[l]);
    while (l + 1 < r) {
      if (l % 2 == 0) ret = f(ret, nodes[l + 1]);
      if (r % 2 == 1) ret = f(ret, nodes[r - 1]);
      l /= 2, r /= 2;
    }
    return ret;
  }
  void update(int l, int r, T val) {
    l += size, r += size;
    nodes[l] += val;
    if (l != r) nodes[r] += val;
    while (l + 1 < r) {
      if (l % 2 == 0) nodes[l + 1] = f(nodes[l + 1], val);
      if (r % 2 == 1) nodes[r - 1] = f(nodes[r - 1], val);
      l /= 2, r /= 2;
    }
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> par(n, -1), dep(n);
  vector<vector<int>> adj(n);
  for (int i = 1; i <= n - 1; i++) {
    cin >> par[i];
    dep[i] = dep[--par[i]] + 1;
    adj[par[i]].emplace_back(i);
  }
  HLD hld(n, adj);
  vector<int> t(n), w(n);
  vector<vector<int>> upd(k);
  for (int i = 0; i < m; i++) {
    int v, d, q;
    cin >> v >> d >> q;
    d--, v--;
    upd[d].emplace_back(v);
    t[v] = d, w[v] = q;
  }
  MaxTree locked(n, {-1, -1});
  SumTree sums(n);
  vector<LL> at(n, -1e18);
  for (int i = 0; i < k; i++) {
    sort(upd[i].begin(), upd[i].end(),
         [&](int a, int b) { return dep[a] > dep[b]; });
    for (int v : upd[i]) {
      at[v] = sums.query(hld.get_vertex(v));
      int u = v;
      LL delta = w[v];
      while (u && delta) {
        auto p = hld.path_up(u, 0);
        int q = -1;
        for (PII &g : p) {
          q = locked.query(g.first, g.second).second;
          if (q != -1) break;
        }
        if (q == -1) {
          for (PII &g : p) sums.update(g.first, g.second, delta);
          sums.update(hld.get_vertex(u), hld.get_vertex(u), -delta);
          break;
        } else {
          p = hld.path_up(u, q);
          for (PII &g : p) sums.update(g.first, g.second, delta);
          sums.update(hld.get_vertex(u), hld.get_vertex(u), -delta);
          LL s = sums.query(hld.get_vertex(q));
          if (s >= at[q] + w[q]) {
            locked.update(hld.get_vertex(q), {-1, -1});
            delta = s - (at[q] + w[q]);
            u = q;
          } else
            break;
        }
      }
      locked.update(hld.get_vertex(v), {dep[v], v});
    }
  }
  cout << max(sums.query(0), at[0] + w[0]) << "\n";
}