#include <bits/stdc++.h>
using namespace std;
int n, p[300005], nrq, code[300005], icode[300005], fin[300005], cnt, cnts = 0;
int lvl[300005], type, node, l, r, v;
int aint1[4 * 300005], aint2[4 * 300005], x, k, val;
long long vall;
char s[32678];
vector<int> G[300005];
inline int get_int() {
  while (s[cnts] < '0' || s[cnts] > '9') {
    if (++cnts == 32678) {
      fread(s, 1, 32678, stdin);
      cnts = 0;
    }
  }
  int x = 0;
  while (s[cnts] >= '0' && s[cnts] <= '9') {
    x = x * 10 + s[cnts] - '0';
    if (++cnts == 32678) {
      fread(s, 1, 32678, stdin);
      cnts = 0;
    }
  }
  return x;
}
void compute_code(int node);
void update_aint(int aint[], int node, int st, int dr);
int query_aint(int aint[], int node, int st, int dr);
int main() {
  int i;
  fread(s, 1, 32678, stdin);
  n = get_int();
  for (i = 2; i <= n; i++) {
    p[i] = get_int();
    G[p[i]].push_back(i);
  }
  compute_code(1);
  nrq = get_int();
  while (nrq--) {
    type = get_int();
    if (type == 1) {
      node = get_int();
      x = get_int();
      k = get_int();
      l = code[node];
      r = fin[node];
      val = (x + 1LL * lvl[node] * k) % 1000000007;
      update_aint(aint1, 1, 1, n);
      val = k;
      update_aint(aint2, 1, 1, n);
    } else {
      node = get_int();
      v = code[node];
      vall = query_aint(aint1, 1, 1, n) -
             1LL * lvl[node] * query_aint(aint2, 1, 1, n);
      if (vall < 0) vall += 1LL * 1000000007 * 1000000007;
      vall %= 1000000007;
      cout << vall << '\n';
    }
  }
  return 0;
}
void compute_code(int node) {
  int i;
  code[node] = (++cnt);
  icode[cnt] = node;
  for (i = 0; i < G[node].size(); i++) {
    lvl[G[node][i]] = lvl[node] + 1;
    compute_code(G[node][i]);
  }
  fin[node] = cnt;
}
void update_aint(int aint[], int node, int st, int dr) {
  if (st >= l && dr <= r) {
    aint[node] += val;
    if (aint[node] > 1000000007) aint[node] -= 1000000007;
    return;
  }
  int mid = (st + dr) >> 1;
  if (l <= mid) update_aint(aint, 2 * node, st, mid);
  if (r >= mid + 1) update_aint(aint, 2 * node + 1, mid + 1, dr);
}
int query_aint(int aint[], int node, int st, int dr) {
  if (st == dr) return aint[node];
  aint[2 * node] += aint[node];
  if (aint[2 * node] > 1000000007) aint[2 * node] -= 1000000007;
  aint[2 * node + 1] += aint[node];
  if (aint[2 * node + 1] > 1000000007) aint[2 * node + 1] -= 1000000007;
  aint[node] = 0;
  int mid = (st + dr) >> 1;
  if (v <= mid) return query_aint(aint, 2 * node, st, mid);
  return query_aint(aint, 2 * node + 1, mid + 1, dr);
}
