#include <bits/stdc++.h>
using namespace std;
const int maxn = 300005;
const int mod = 1000000007;
vector<int> G[maxn];
int l[maxn], r[maxn], d[maxn], nn = 0;
void dfs(int u, int dep) {
  d[u] = dep;
  l[u] = ++nn;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    dfs(v, dep + 1);
  }
  r[u] = nn;
}
long long a[maxn << 2], b[maxn << 2];
void maintain(int rt, long long *c) {
  if (c[rt]) {
    c[rt << 1] += c[rt];
    c[rt << 1] %= mod;
    c[rt << 1 | 1] += c[rt];
    c[rt << 1 | 1] %= mod;
    c[rt] = 0;
  }
}
void pushdown(int rt) {
  maintain(rt, a);
  maintain(rt, b);
}
void update(int L, int R, long long x, long long k, int l, int r, int rt) {
  if (L <= l && r <= R) {
    a[rt] += x;
    a[rt] %= mod;
    b[rt] += k;
    b[rt] %= mod;
    return;
  }
  pushdown(rt);
  int m = (l + r) >> 1;
  if (L <= m) update(L, R, x, k, l, m, rt << 1);
  if (R > m) update(L, R, x, k, m + 1, r, rt << 1 | 1);
}
int query(int pos, int l, int r, int rt) {
  if (l == r) {
    return rt;
  }
  pushdown(rt);
  int m = (l + r) >> 1;
  if (pos <= m)
    return query(pos, l, m, rt << 1);
  else
    return query(pos, m + 1, r, rt << 1 | 1);
}
int main() {
  int n, p;
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &p);
    G[p].push_back(i);
  }
  dfs(1, 1);
  int q, t, v;
  long long x, k;
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &t);
    if (t == 1) {
      scanf("%d%I64d%I64d", &v, &x, &k);
      x += k * d[v];
      x %= mod;
      update(l[v], r[v], x, k, 1, n, 1);
    } else if (t == 2) {
      scanf("%d", &v);
      int id = query(l[v], 1, n, 1);
      long long ans = (a[id] - d[v] * b[id]) % mod;
      printf("%I64d\n", (ans + mod) % mod);
    }
  }
  return 0;
}
