#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
vector<int> adj[N];
int depth[N];
int tin[N];
int tout[N];
long long bit1[2 * N];
long long bit2[2 * N];
inline void update(long long tree[], int idx, long long val) {
  while (idx < 2 * N) {
    tree[idx] += val;
    tree[idx] %= 1000000007;
    tree[idx] += 1000000007;
    tree[idx] %= 1000000007;
    idx += idx & -idx;
  }
}
inline long long query(long long tree[], int idx) {
  long long sm = 0;
  while (idx > 0) {
    sm += tree[idx];
    sm %= 1000000007;
    idx -= idx & -idx;
  }
  return sm;
}
inline void dfs(int u, int par) {
  static int timer = 0;
  tin[u] = ++timer;
  if (par != -1) {
    depth[u] = 1 + depth[par];
  }
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (v == par) continue;
    dfs(v, u);
  }
  tout[u] = ++timer;
}
int main() {
  int n;
  scanf("%d", &n);
  ;
  for (int i = 2; i < n + 1; i++) {
    int x;
    scanf("%d", &x);
    ;
    adj[x].push_back(i);
  }
  dfs(1, -1);
  int q;
  scanf("%d", &q);
  ;
  while (q--) {
    long long node, x, k, tp;
    scanf("%lld", &tp);
    ;
    if (tp == 1) {
      scanf("%lld", &node);
      ;
      scanf("%lld", &x);
      ;
      scanf("%lld", &k);
      ;
      long long val = x + depth[node] * k;
      val %= 1000000007;
      update(bit1, tin[node], val);
      update(bit1, tout[node] + 1, -val);
      update(bit2, tin[node], k);
      update(bit2, tout[node] + 1, -k);
    } else {
      scanf("%lld", &node);
      ;
      long long ans = 0;
      ans += query(bit1, tin[node]);
      ans %= 1000000007;
      ans = ans - (1LL * depth[node] * query(bit2, tin[node])) % 1000000007;
      printf("%lld\n", (ans + 1000000007) % 1000000007);
    }
  }
}
