#include <bits/stdc++.h>
using namespace std;
const long N = 3e5 + 5, mod = 1e9 + 7;
vector<int> ed[N], a, lev(N), sz(N);
long long tp[2 * N], ts[2 * N];
int n;
int dfs(int u, int l) {
  a.push_back(u);
  lev[u] = l;
  int s = 0;
  for (int v : ed[u]) s += dfs(v, l + 1);
  return sz[u] = s + 1;
}
void up(long long t[], int l, int r, long long val) {
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) t[l] = (t[l] + val) % mod, l++;
    if (r & 1) --r, t[r] = (t[r] + val) % mod;
  }
}
long long qry(long long t[], int p) {
  long long res = 0;
  for (p += n; p >= 1; p >>= 1) res = (res + t[p]) % mod;
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  int ind[n + 1], next_ind[n + 1], p;
  for (int i = 2; i < n + 1; i++) {
    cin >> p;
    ed[p].push_back(i);
  }
  dfs(1, 0);
  for (int i = 0; i < n; i++) ind[a[i]] = i;
  for (int i = 1; i < n + 1; i++) next_ind[i] = ind[i] + sz[i];
  int t;
  cin >> t;
  while (t--) {
    int ch;
    cin >> ch;
    if (ch == 1) {
      long long v, x, k;
      cin >> v >> x >> k;
      up(tp, ind[v], next_ind[v], (x + lev[v] * k) % mod);
      up(ts, ind[v], next_ind[v], k);
    } else {
      int v;
      cin >> v;
      long long ans =
          (qry(tp, ind[v]) - lev[v] * qry(ts, ind[v]) % mod + mod) % mod;
      cout << ans << "\n";
    }
  }
}
