#include <bits/stdc++.h>
using namespace std;
const int maxn = 3 * 1e5 + 3;
const long long mod = 1e9 + 7;
int n, m, in[maxn], out[maxn], cnt = 0, avail[maxn];
long long lev[maxn], hkx[4 * maxn], sk[4 * maxn];
vector<int> g[maxn];
void DFS(int u) {
  avail[u] = 1;
  in[u] = ++cnt;
  for (int i = 0; i < g[u].size(); ++i) {
    int v = g[u][i];
    if (avail[v] == 0) {
      lev[v] = lev[u] + 1;
      DFS(v);
    }
  }
  out[u] = cnt;
}
void Update(int node, int start, int endd, int v, long long x, long long k) {
  if (in[v] > endd || out[v] < start || start > endd) {
    return;
  }
  if (in[v] <= start && endd <= out[v]) {
    hkx[node] = (hkx[node] + x + k * lev[v]) % mod;
    sk[node] = (sk[node] + k) % mod;
    return;
  }
  int mid = (start + endd) / 2;
  Update(2 * node, start, mid, v, x, k);
  Update(2 * node + 1, mid + 1, endd, v, x, k);
}
long long Ans(int node, int start, int endd, int v) {
  if (in[v] > endd || in[v] < start) {
    return 0;
  }
  long long res = hkx[node] % mod;
  res = (res + mod * mod - lev[v] * sk[node]) % mod;
  if (start == endd) {
    return (res % mod);
  }
  int mid = (start + endd) / 2;
  long long l = Ans(2 * node, start, mid, v) % mod;
  long long r = Ans(2 * node + 1, mid + 1, endd, v) % mod;
  return ((res + l + r) % mod);
}
void BuildGraph() {
  scanf("%d", &n);
  for (int i = 2; i <= n; ++i) {
    int p;
    scanf("%d", &p);
    g[p].push_back(i), g[i].push_back(p);
  }
}
void Query() {
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) {
    int type;
    scanf("%d", &type);
    if (type == 1) {
      int v;
      long long x, k;
      scanf("%d%lld%lld", &v, &x, &k);
      Update(1, 1, n, v, x, k);
    }
    if (type == 2) {
      int v;
      scanf("%d", &v);
      printf("%lld\n", (Ans(1, 1, n, v) % mod));
    }
  }
}
int main() {
  BuildGraph();
  lev[1] = 1;
  DFS(1);
  Query();
}
