#include <bits/stdc++.h>
using namespace std;
const long long int maxn = 3e5 + 5, M = 1e6 + 5, bghs = 1e9 + 7, inf = 1e18,
                    Z = maxn / 2;
long long int n, q;
vector<long long int> adj[maxn];
long long int ftst = 0, ft[maxn], st[maxn], h[maxn];
bool mark[maxn];
struct segmen {
  long long int seg[4 * maxn], lazy[4 * maxn];
  void shif(long long int id) {
    lazy[id * 2 + 1] += lazy[id];
    lazy[id * 2 + 2] += lazy[id];
    seg[id * 2 + 1] += lazy[id];
    seg[id * 2 + 2] += lazy[id];
    lazy[id] = 0;
    lazy[id * 2 + 1] %= bghs;
    lazy[id * 2 + 2] %= bghs;
    seg[id * 2 + 1] %= bghs;
    seg[id * 2 + 2] %= bghs;
  }
  void upd(long long int s, long long int e, long long int val,
           long long int l = 0, long long int r = n, long long int id = 0) {
    if (e <= l || r <= s) return;
    if (s <= l && r <= e) {
      seg[id] += val;
      lazy[id] += val;
      seg[id] %= bghs;
      lazy[id] %= bghs;
      return;
    }
    shif(id);
    long long int mid = (r + l) >> 1;
    upd(s, e, val, l, mid, 2 * id + 1);
    upd(s, e, val, mid, r, 2 * id + 2);
    seg[id] = (seg[id * 2 + 1] + seg[id * 2 + 2]) % bghs;
  }
  long long int get(long long int x, long long int l = 0, long long int r = n,
                    long long int id = 0) {
    if (r - l == 1) return seg[id];
    shif(id);
    long long int mid = (r + l) >> 1, y = 0;
    if (x < mid)
      y = get(x, l, mid, 2 * id + 1);
    else
      y = get(x, mid, r, 2 * id + 2);
    return y;
  }
};
segmen s1, s2;
void dfs(long long int root) {
  st[root] = ftst++;
  mark[root] = true;
  for (long long int y : adj[root])
    if (!mark[y]) {
      h[y] = h[root] + 1;
      dfs(y);
    }
  ft[root] = ftst;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    long long int p;
    cin >> p;
    p--;
    adj[p].push_back(i);
    adj[i].push_back(p);
  }
  dfs(0);
  cin >> q;
  while (q--) {
    long long int t, v;
    cin >> t >> v;
    v--;
    if (t == 1) {
      long long int x, k;
      cin >> x >> k;
      s1.upd(st[v], ft[v], (x + h[v] * k) % bghs);
      s2.upd(st[v], ft[v], k);
    }
    if (t == 2) {
      cout << (((s1.get(st[v]) - s2.get(st[v]) * h[v]) % bghs) + bghs) % bghs
           << "\n";
    }
  }
}
