#include <bits/stdc++.h>
using namespace std;
const int basic = 1e9 + 7;
struct Node {
  int x;
  int buff;
  Node(int x = 0) : x(x), buff(0) {}
};
const int max_n = 1 << 19;
void append(int& a, int& b) {
  a += b;
  if (a >= basic) a -= basic;
}
struct Segment_Tree {
  vector<Node> t;
  Segment_Tree() { t.resize(max_n * 2); }
  void push(int v) {
    if (t[v].buff == 0) return;
    append(t[v].x, t[v].buff);
    if (v < max_n) {
      append(t[v * 2].buff, t[v].buff);
      append(t[v * 2 + 1].buff, t[v].buff);
    }
    t[v].buff = 0;
  }
  void add(int l, int r, int val, int tl = 0, int tr = max_n - 1, int v = 1) {
    push(v);
    if (r < tl || l > tr) return;
    if (r >= tr && l <= tl) {
      append(t[v].buff, val);
      push(v);
      return;
    }
    add(l, r, val, tl, (tl + tr) / 2LL, v * 2);
    add(l, r, val, (tl + tr) / 2LL + 1, tr, v * 2 + 1);
  }
  int get(int pos, int tl = 0, int tr = max_n - 1, int v = 1) {
    push(v);
    if (tl > pos || tr < pos) return 0;
    if (tl == pos && tr == pos) return t[v].x;
    return get(pos, tl, (tl + tr) / 2LL, v * 2) +
           get(pos, (tl + tr) / 2LL + 1, tr, v * 2 + 1);
  }
};
const int N = 3e5 + 5;
vector<int> Edge[N];
int L[N], R[N], deep[N];
bool used[N];
extern int dfs_time = 0;
void dfs(int v, int d = 0) {
  used[v] = true;
  deep[v] = ++d;
  L[v] = dfs_time++;
  for (int i = 0; i < Edge[v].size(); i++) {
    if (!used[Edge[v][i]]) dfs(Edge[v][i], d);
  }
  R[v] = dfs_time - 1;
}
signed main() {
  ios_base::sync_with_stdio((false));
  cin.tie(0);
  cout.tie(0);
  Segment_Tree t1 = Segment_Tree();
  Segment_Tree t2 = Segment_Tree();
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int p;
    cin >> p;
    p--;
    Edge[p].push_back(i);
    Edge[i].push_back(p);
  }
  dfs(0);
  int q;
  cin >> q;
  while (q--) {
    int type;
    cin >> type;
    if (type - 1) {
      int v;
      cin >> v;
      v--;
      cout << (t1.get(L[v]) -
               ((int64_t(t2.get(L[v])) * int64_t(deep[v])) % basic) + basic) %
                  basic
           << '\n';
    } else {
      int v, x, k;
      cin >> v >> x >> k;
      v--;
      t1.add(L[v], R[v], (int64_t(x) + int64_t(k) * int64_t(deep[v])) % basic);
      t2.add(L[v], R[v], k);
    }
  }
  return 0;
}
