#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7, N = 2e6;
struct fenwick {
  long long arr[N];
  void ADD(long long ind, long long val) {
    for (; ind < N; ind += ind & -ind) arr[ind] = (arr[ind] + val) % MOD;
  }
  long long GET(long long ind) {
    long long sum = 0;
    for (; ind > 0; ind -= ind & -ind) sum = (sum + arr[ind]) % MOD;
    return sum;
  }
};
fenwick f1, f2;
long long h[N], p[N], st[N], ft[N], t = 1;
vector<long long> adj[N];
void DFS(long long u) {
  st[u] = t++;
  for (long long v : adj[u])
    if (v != p[u]) DFS(v);
  ft[u] = t;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = 2; i <= n; i++) {
    cin >> p[i];
    h[i] = h[p[i]] + 1;
    adj[p[i]].push_back(i);
  }
  DFS(1);
  long long q;
  cin >> q;
  while (q--) {
    long long f, v, x, k;
    cin >> f >> v;
    if (f == 1) {
      cin >> x >> k;
      f1.ADD(st[v], x + h[v] * k);
      f1.ADD(ft[v], -(x + h[v] * k));
      f2.ADD(st[v], k);
      f2.ADD(ft[v], -k);
    } else
      cout << ((f1.GET(st[v]) - (h[v] * f2.GET(st[v]))) % MOD + MOD) % MOD
           << '\n';
  }
  return 0;
}
