#include <bits/stdc++.h>
using namespace std;
pair<int, int> add(pair<int, int> a, pair<int, int> b) {
  return {(a.first + b.first) % 1000000007, (a.second + b.second) % 1000000007};
}
pair<int, int> aint[1200010];
int l, r, poz;
pair<int, int> f;
void update(int nod, int st, int dr) {
  if (st > r || dr < l) return;
  if (l <= st && r >= dr) {
    aint[nod] = add(aint[nod], f);
    return;
  }
  update(2 * nod, st, (st + dr) / 2);
  update(2 * nod + 1, (st + dr) / 2 + 1, dr);
}
pair<int, int> query(int nod, int st, int dr) {
  if (st > poz || dr < poz) return {0, 0};
  if (st == dr) return aint[nod];
  return add(add(aint[nod], query(2 * nod, st, (st + dr) / 2)),
             query(2 * nod + 1, (st + dr) / 2 + 1, dr));
}
vector<int> adia[400010];
int firstap[400010], lastap[400010];
int h[400010];
int cnt;
void dfs(int nod, int tata) {
  h[nod] = 1 + h[tata];
  firstap[nod] = ++cnt;
  for (auto i : adia[nod])
    if (i != tata) dfs(i, nod);
  lastap[nod] = cnt;
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  int n, a, b;
  cin >> n;
  for (int i(2); i <= n; i++) {
    cin >> a;
    adia[a].push_back(i);
  }
  dfs(1, 0);
  int q, v, x, k, t;
  cin >> q;
  while (q--) {
    cin >> t;
    if (t == 1) {
      cin >> v >> x >> k;
      f = {(x + 1ll * h[v] * k) % 1000000007, -k};
      l = firstap[v], r = lastap[v];
      update(1, 1, cnt);
    } else {
      cin >> v;
      poz = firstap[v];
      pair<int, int> z = query(1, 1, cnt);
      cout << ((z.first + 1ll * h[v] * z.second) % 1000000007 + 1000000007) %
                  1000000007
           << '\n';
    }
  }
  return 0;
}
