#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int maxn = 300010;
struct edge {
  int to, next;
} e[maxn];
int num, n, q, x, b, cnt;
long long ans, sum, v, k;
int in[maxn], out[maxn];
long long dep[maxn], f[2][maxn], head[maxn];
void addedge(int x, int y) {
  num++;
  e[num].to = y;
  e[num].next = head[x];
  head[x] = num;
}
void dfs(int k) {
  in[k] = ++cnt;
  for (int j = head[k]; j; j = e[j].next) {
    dep[e[j].to] = dep[k] + 1;
    dfs(e[j].to);
  }
  out[k] = cnt;
}
int lowbit(int s) { return s & -s; }
void add(int z, long long w, int b) {
  for (; z <= cnt; z += lowbit(z)) f[b][z] = (f[b][z] + w) % mod;
}
long long query(int z, int b) {
  long long c = 0;
  for (; z; z -= lowbit(z)) c = (c + f[b][z]) % mod;
  return c;
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &x);
    addedge(x, i);
  }
  dep[1] = 1;
  dfs(1);
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &b);
    if (b == 1) {
      scanf("%d%d%d", &x, &v, &k);
      v = (v + dep[x] * k) % mod;
      add(in[x], v, 0);
      add(out[x] + 1, -v, 0);
      add(in[x], k, 1);
      add(out[x] + 1, -k, 1);
    } else {
      scanf("%d", &x);
      ans = query(in[x], 0);
      sum = query(in[x], 1);
      ans = ((ans - sum * dep[x]) % mod + (long long)mod) % mod;
      printf("%I64d\n", ans);
    }
  }
  return 0;
}
