#include <bits/stdc++.h>
using namespace std;
int n;
int ti = 0;
int P[300001], L[300001], H[300001];
vector<int> adj[300001];
void dfs(int u, int h = 0) {
  P[u] = ti++;
  H[u] = h;
  for (int i = 0; i < adj[u].size(); ++i) dfs(adj[u][i], h + 1);
  L[u] = ti - 1;
}
inline long long san(long long x) {
  if (x >= 1000000007) x %= 1000000007;
  return x;
}
struct ST {
  long long *st, *add;
  ST() {
    st = new long long[1048580];
    add = new long long[1048580];
    memset(st, 0, 1048580 << 3);
    memset(add, 0, 1048580 << 3);
  }
  ~ST() {
    delete[] st;
    delete[] add;
  }
  inline void push(int idx, int l, int r, int L, int R) {
    if (add[idx]) {
      st[idx] = san(st[idx] + add[idx] * (r - l + 1));
      if (l != r) {
        add[L] = san(add[L] + add[idx]);
        add[R] = san(add[R] + add[idx]);
      }
      add[idx] = 0;
    }
  }
  void stupdate(int i, int j, long long up, int idx = 0, int l = 0,
                int r = n - 1) {
    int L = (idx << 1) + 1, R = L + 1;
    if (l >= i and r <= j) add[idx] = san(add[idx] + up);
    push(idx, l, r, L, R);
    if ((l >= i and r <= j) or r < i or l > j) return;
    int mid = (l + r) >> 1;
    stupdate(i, j, up, L, l, mid);
    stupdate(i, j, up, R, mid + 1, r);
    st[idx] = san(st[L] + st[R]);
  }
  long long stq(int i, int idx = 0, int l = 0, int r = n - 1) {
    int L = (idx << 1) + 1, R = L + 1;
    push(idx, l, r, L, R);
    if (l >= i and r <= i) return st[idx];
    if (r < i or l > i) return 0;
    int mid = (l + r) >> 1;
    return san(stq(i, L, l, mid) + stq(i, R, mid + 1, r));
  }
};
int main() {
  std::ios::sync_with_stdio(false);
  int m, op, v;
  long long x, k;
  cin >> n;
  for (int i = 1; i < n; ++i) {
    cin >> x;
    adj[x - 1].push_back(i);
  }
  dfs(0);
  cin >> m;
  ST A, B;
  long long ans;
  while (m--) {
    cin >> op >> v;
    --v;
    if (op == 2) {
      ans = (A.stq(P[v]) - B.stq(P[v]) * H[v]) % 1000000007;
      if (ans < 0) ans += 1000000007;
      cout << ans << endl;
    } else {
      cin >> x >> k;
      A.stupdate(P[v], L[v], san(x + H[v] * k));
      B.stupdate(P[v], L[v], k);
    }
  }
}
