#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
long long in[300009], out[300009], tim, s[300009 << 2], t[300009 << 2],
    lvl[300009];
vector<long long> adj[300009];
void dfs(long long nd, long long pr) {
  in[nd] = ++tim;
  lvl[nd] = lvl[pr] + 1;
  for (long long i = 0; i < adj[nd].size(); i++) dfs(adj[nd][i], nd);
  out[nd] = tim;
}
void shift(long long nd) {
  s[nd << 1] = (s[nd << 1] + s[nd]) % 1000000007;
  s[nd << 1 | 1] = (s[nd << 1 | 1] + s[nd]) % 1000000007;
  s[nd] = 0;
}
void shif(long long nd) {
  t[nd << 1] = (t[nd << 1] + t[nd]) % 1000000007;
  t[nd << 1 | 1] = (t[nd << 1 | 1] + t[nd]) % 1000000007;
  t[nd] = 0;
}
void upd(long long l, long long r, long long v, long long nd, long long x,
         long long y) {
  if (l > y or x > r) return;
  if (l <= x and y <= r) {
    s[nd] = (v + s[nd]) % 1000000007;
    return;
  }
  shift(nd);
  long long mid = (x + y) >> 1;
  upd(l, r, v, nd * 2, x, mid);
  upd(l, r, v, nd * 2 + 1, mid + 1, y);
}
void up(long long l, long long r, long long v, long long nd, long long x,
        long long y) {
  if (l > y or x > r) return;
  if (l <= x and y <= r) {
    t[nd] = (t[nd] + v) % 1000000007;
    return;
  }
  shif(nd);
  long long mid = (x + y) >> 1;
  up(l, r, v, nd * 2, x, mid);
  up(l, r, v, nd * 2 + 1, mid + 1, y);
}
long long tap(long long p, long long nd, long long x, long long y) {
  if (x == y) return s[nd];
  shift(nd);
  long long mid = (x + y) >> 1;
  if (p <= mid) return tap(p, nd * 2, x, mid);
  return tap(p, nd * 2 + 1, mid + 1, y);
}
long long ta(long long p, long long nd, long long x, long long y) {
  if (x == y) return t[nd];
  shif(nd);
  long long mid = (x + y) >> 1;
  if (p <= mid) return ta(p, nd * 2, x, mid);
  return ta(p, nd * 2 + 1, mid + 1, y);
}
int main() {
  long long a;
  scanf("%lld", &a);
  for (long long i = 2; i <= a; i++) {
    long long u;
    scanf("%lld", &u);
    adj[u].push_back(i);
  }
  dfs(1, 0);
  long long q;
  scanf("%lld", &q);
  while (q--) {
    long long type, v;
    scanf("%lld%lld", &type, &v);
    if (type == 1) {
      long long x, k;
      scanf("%lld%lld", &x, &k);
      upd(in[v], out[v], (x + (lvl[v] * k)) % 1000000007, 1, 1, tim);
      up(in[v], out[v], k, 1, 1, tim);
    } else
      printf("%lld\n",
             (tap(in[v], 1, 1, tim) -
              (lvl[v] * ta(in[v], 1, 1, tim)) % 1000000007 + 1000000007) %
                 1000000007);
  }
  return 0;
}
