#include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 7;
int n, q, p, type, u, x, k, in[300005], ou[300005], h[300005], cnt;
long long bit[300005][2];
vector<int> a[300005];
void dfs(int u) {
  in[u] = ++cnt;
  for (int v : a[u]) {
    h[v] = h[u] + 1;
    dfs(v);
  }
  ou[u] = cnt;
}
void update(int u, long long v, int type) {
  while (u <= cnt) {
    bit[u][type] += v;
    bit[u][type] %= mod;
    u += (u & (-u));
  }
}
long long get(int u, int type) {
  int ans(0);
  while (u > 0) {
    ans += bit[u][type];
    ans %= mod;
    u -= (u & (-u));
  }
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> p;
    a[p].push_back(i + 1);
  }
  dfs(1);
  cin >> q;
  while (q--) {
    cin >> type >> u;
    if (type == 2) {
      long long val1 = get(in[u], 0), val2 = get(in[u], 1);
      long long ans(val1 - 1LL * val2 * h[u]);
      cout << (ans % mod + mod) % mod << "\n";
    } else {
      cin >> x >> k;
      int newl = in[u], newr = ou[u];
      long long val1 = (x + 1LL * h[u] * k), val2 = k;
      update(newl, val1, 0), update(newr + 1, -val1, 0);
      update(newl, val2, 1), update(newr + 1, -val2, 1);
    }
  }
  return 0;
}
