#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int maxn = 3000033;
struct BIT {
  int a[maxn];
  BIT() { memset((a), (0), sizeof(a)); }
  void add(int i, int x) {
    for (++i; i < maxn; i += -i & i) {
      a[i] += x;
      if (a[i] >= mod) a[i] -= mod;
    }
  }
  int sum(int i) {
    int s = 0;
    for (++i; i > 0; i -= -i & i) {
      s += a[i];
      if (s >= mod) s -= mod;
    }
    return s;
  }
  void add(int i, int j, int x) {
    add(i, x);
    add(j + 1, mod - x);
  }
};
vector<int> g[maxn];
int level[maxn];
int tin[maxn];
int tout[maxn];
void dfs(int at, int from, int depth) {
  static int timer = -1;
  level[at] = depth;
  tin[at] = ++timer;
  for (int to : g[at]) {
    if (to == from) continue;
    dfs(to, at, depth + 1);
  }
  tout[at] = timer;
}
BIT b1, b2;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int _n(n - 1), i(0); i < _n; i++) {
    int x = i + 1;
    int y;
    cin >> y;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(0, -1, 0);
  int q;
  cin >> q;
  for (int _n(q), i(0); i < _n; i++) {
    int op;
    cin >> op;
    if (op == 1) {
      int v, x, k;
      cin >> v >> x >> k;
      --v;
      b1.add(tin[v], tout[v], (x + 1ll * k * level[v] % mod) % mod);
      b2.add(tin[v], tout[v], k);
    } else {
      int v;
      cin >> v;
      --v;
      int a1 = b1.sum(tin[v]);
      int a2 = b2.sum(tin[v]);
      long long ans = (1ll * a1 - (1ll * a2 * level[v] % mod) + mod) % mod;
      cout << ans << endl;
    }
  }
  return 0;
}
