#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T gcd(T a, T b) {
  return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd<T>(a, b) * b);
}
template <class T>
inline T bigmod(T p, T e, T M) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    long long int t = bigmod(p, e / 2, M);
    return (T)((t * t) % M);
  }
  return (T)((long long int)bigmod(p, e - 1, M) * (long long int)p) % M;
}
template <class T>
inline T bigexp(T p, T e) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    long long int t = bigexp(p, e / 2);
    return (T)((t * t));
  }
  return (T)((long long int)bigexp(p, e - 1) * (long long int)p);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
int dx4[] = {1, 0, -1, 0};
int dy4[] = {0, 1, 0, -1};
int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
int month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
long long int BIT[2][300005], segment_rnge[300005][2], level[300005], n, p, q,
    v, x, k, c;
vector<long long int> edges[300005];
void update(long long int t, long long int idx, long long int x) {
  while (idx <= n) {
    BIT[t][idx] = (BIT[t][idx] + x + 1000000007) % 1000000007;
    idx = idx + (idx & -idx);
  }
}
long long int query(long long int t, long long int idx) {
  long long int res = 0;
  while (idx) {
    res = (res + BIT[t][idx] + 1000000007) % 1000000007;
    idx -= (idx & -idx);
  }
  return res;
}
void dfs(long long int node, long long int l) {
  level[node] = l;
  int sz = edges[node].size();
  segment_rnge[node][0] = ++c;
  for (int i = 0; i < sz; i++) {
    long long int v = edges[node][i];
    dfs(v, l + 1);
  }
  segment_rnge[node][1] = c;
}
int main() {
  scanf("%I64d", &n);
  for (__typeof(n) i = (2); i <= (n); i++) {
    scanf("%I64d", &p);
    edges[p].push_back(i);
  }
  dfs(1, 0);
  scanf("%I64d", &q);
  while (q--) {
    scanf("%I64d", &p);
    if (p == 1) {
      scanf("%I64d %I64d %I64d", &v, &x, &k);
      update(0, segment_rnge[v][0],
             (x + (level[v] * k) % 1000000007) % 1000000007);
      update(0, segment_rnge[v][1] + 1,
             (1000000007 - (x + (level[v] * k) % 1000000007)) % 1000000007);
      update(1, segment_rnge[v][0], -k);
      update(1, segment_rnge[v][1] + 1, k);
    } else {
      scanf("%I64d", &p);
      long long int res =
          (query(0, segment_rnge[p][0]) % 1000000007 +
           (query(1, segment_rnge[p][0]) * level[p]) % 1000000007) %
          1000000007;
      printf("%I64d\n", res);
    }
  }
  for (__typeof(n) i = (0); i <= (n); i++) edges[i].clear();
  return 0;
}
