#include <bits/stdc++.h>
using namespace std;
int n, Q, deg[3 * 100005];
vector<int> g[3 * 100005];
int it1[4 * 3 * 100005], gt1[4 * 3 * 100005];
int it2[4 * 3 * 100005], gt2[4 * 3 * 100005];
int cl[3 * 100005], depth[3 * 100005], head[3 * 100005], tail[3 * 100005],
    x[3 * 100005];
int cur[3 * 100005], s[3 * 100005];
void dfs() {
  int sn = 0, slx = 0;
  s[++sn] = 1;
  cl[1] = 1;
  depth[1] = 1;
  x[++slx] = 1;
  head[1] = slx;
  while (sn) {
    int u = s[sn];
    while (cur[u] < deg[u] && cl[g[u][cur[u]]]) cur[u]++;
    if (cur[u] == deg[u]) {
      tail[u] = slx;
      sn--;
    } else {
      int v = g[u][cur[u]];
      cl[v] = 1;
      s[++sn] = v;
      depth[v] = depth[u] + 1;
      x[++slx] = v;
      head[v] = slx;
    }
  }
}
void update1(int r, int k, int l, int u, int v, int val) {
  if (v < k || u > l) return;
  if (u <= k && l <= v) {
    gt1[r] = (gt1[r] + val) % 1000000007;
    return;
  }
  int g = (k + l) / 2;
  gt1[2 * r] = (gt1[2 * r] + gt1[r]) % 1000000007;
  gt1[2 * r + 1] = (gt1[2 * r + 1] + gt1[r]) % 1000000007;
  gt1[r] = 0;
  update1(2 * r, k, g, u, v, val);
  update1(2 * r + 1, g + 1, l, u, v, val);
  int trai = (it1[2 * r] + (g - k + 1) * (long long)gt1[2 * r]) % 1000000007;
  int phai =
      (it1[2 * r + 1] + (l - g) * (long long)gt1[2 * r + 1]) % 1000000007;
  it1[r] = (trai + phai) % 1000000007;
}
int get1(int r, int k, int l, int u, int v) {
  if (v < k || u > l) return 0;
  if (u <= k && l <= v)
    return (it1[r] + (l - k + 1) * (long long)gt1[r]) % 1000000007;
  int g = (k + l) / 2;
  gt1[2 * r] = (gt1[2 * r] + gt1[r]) % 1000000007;
  gt1[2 * r + 1] = (gt1[2 * r + 1] + gt1[r]) % 1000000007;
  gt1[r] = 0;
  int t1 = get1(2 * r, k, g, u, v);
  int t2 = get1(2 * r + 1, g + 1, l, u, v);
  int trai = (it1[2 * r] + (g - k + 1) * (long long)gt1[2 * r]) % 1000000007;
  int phai =
      (it1[2 * r + 1] + (l - g) * (long long)gt1[2 * r + 1]) % 1000000007;
  it1[r] = (trai + phai) % 1000000007;
  return (t1 + t2) % 1000000007;
}
void update2(int r, int k, int l, int u, int v, int val) {
  if (v < k || u > l) return;
  if (u <= k && l <= v) {
    gt2[r] = (gt2[r] + val) % 1000000007;
    return;
  }
  int g = (k + l) / 2;
  gt2[2 * r] = (gt2[2 * r] + gt2[r]) % 1000000007;
  gt2[2 * r + 1] = (gt2[2 * r + 1] + gt2[r]) % 1000000007;
  gt2[r] = 0;
  update2(2 * r, k, g, u, v, val);
  update2(2 * r + 1, g + 1, l, u, v, val);
  int trai = (it2[2 * r] + (g - k + 1) * (long long)gt2[2 * r]) % 1000000007;
  int phai =
      (it2[2 * r + 1] + (l - g) * (long long)gt2[2 * r + 1]) % 1000000007;
  it2[r] = (trai + phai) % 1000000007;
}
int get2(int r, int k, int l, int u, int v) {
  if (v < k || u > l) return 0;
  if (u <= k && l <= v)
    return (it2[r] + (l - k + 1) * (long long)gt2[r]) % 1000000007;
  int g = (k + l) / 2;
  gt2[2 * r] = (gt2[2 * r] + gt2[r]) % 1000000007;
  gt2[2 * r + 1] = (gt2[2 * r + 1] + gt2[r]) % 1000000007;
  gt2[r] = 0;
  int t1 = get2(2 * r, k, g, u, v);
  int t2 = get2(2 * r + 1, g + 1, l, u, v);
  int trai = (it2[2 * r] + (g - k + 1) * (long long)gt2[2 * r]) % 1000000007;
  int phai =
      (it2[2 * r + 1] + (l - g) * (long long)gt2[2 * r + 1]) % 1000000007;
  it2[r] = (trai + phai) % 1000000007;
  return (t1 + t2) % 1000000007;
}
void lam1() {
  int v, x, k;
  cin >> v >> x >> k;
  int val =
      ((x + depth[v] * (long long)k) % 1000000007 + 1000000007) % 1000000007;
  update1(1, 1, n, head[v], tail[v], val);
  update2(1, 1, n, head[v], tail[v], (-k + 1000000007) % 1000000007);
}
void lam2() {
  int v;
  cin >> v;
  int p1 = get1(1, 1, n, head[v], head[v]);
  int p2 = get2(1, 1, n, head[v], head[v]);
  int ds =
      ((p1 + (long long)p2 * depth[v]) % 1000000007 + 1000000007) % 1000000007;
  cout << ds << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int p;
    cin >> p;
    deg[p]++;
    g[p].push_back(i);
    deg[i]++;
    g[i].push_back(p);
  }
  dfs();
  cin >> Q;
  for (int i = 1; i <= Q; i++) {
    int id;
    cin >> id;
    if (id == 1)
      lam1();
    else
      lam2();
  }
}
