#include <bits/stdc++.h>
using namespace std;
vector<int> g[500008];
int st[500008], en[500008];
int Time;
long long int lazy1[4 * 500008], lazy2[4 * 500008];
long long int tree[2][4 * 500008];
int lvl[500008];
const long long int mod = (long long int)1e9 + 7;
void dfs(int src, int par, int l) {
  st[src] = ++Time;
  lvl[src] = l;
  for (auto i : g[src]) {
    if (i == par) {
      continue;
    }
    dfs(i, src, l + 1);
  }
  en[src] = Time;
}
void propagate(int node, int b, int e) {
  if (lazy1[node]) {
    long long int val = lazy1[node];
    tree[0][node] += (lazy1[node] + mod) % mod;
    tree[0][node] = (tree[0][node] + mod) % mod;
    if (b != e) {
      lazy1[(2 * node) + 1] = (lazy1[(2 * node) + 1] + val + mod) % mod;
      lazy1[(2 * node)] = (lazy1[(2 * node)] + val + mod) % mod;
    }
    lazy1[node] = 0;
  }
  if (lazy2[node]) {
    tree[1][node] += (lazy2[node] + mod) % mod;
    tree[1][node] = (tree[1][node] + mod) % mod;
    long long int val = lazy2[node];
    if (b != e) {
      lazy2[(2 * node)] = (lazy2[(2 * node)] + val + mod) % mod;
      lazy2[(2 * node) + 1] = (lazy2[(2 * node) + 1] + val + mod) % mod;
    }
    lazy2[node] = 0;
  }
  return;
}
void update(int node, int b, int e, int i, int j, int val, int id) {
  propagate(node, b, e);
  if (i > e || j < b) {
    return;
  }
  if (b >= i && e <= j) {
    tree[id][node] = (tree[id][node] + mod + val) % mod;
    if (id == 0) {
      if (b != e) {
        lazy1[2 * node] = (lazy1[2 * node] + val) % mod;
        lazy1[(2 * node) + 1] = (lazy1[(2 * node) + 1] + val) % mod;
      }
    } else {
      if (b != e) {
        lazy2[(2 * node)] = (lazy2[(2 * node)] + val) % mod;
        lazy2[(2 * node) + 1] = (lazy2[(2 * node) + 1] + val) % mod;
      }
    }
    return;
  }
  int mid = (b + e) >> 1;
  int left = node << 1;
  int right = left + 1;
  update(left, b, mid, i, j, val, id);
  update(right, mid + 1, e, i, j, val, id);
}
long long int query(int node, int b, int e, int i, int j, int val) {
  propagate(node, b, e);
  if (i > e || j < b) {
    return 0;
  }
  if (b >= i && e <= j) {
    long long int temp =
        ((tree[0][node] - (val % mod * tree[1][node] % mod) % mod) + mod) % mod;
    return temp % mod;
  }
  int mid = (b + e) >> 1;
  int left = node << 1;
  int right = left + 1;
  return query(left, b, mid, i, j, val) + query(right, mid + 1, e, i, j, val);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int x, u;
    cin >> x;
    g[i].push_back(x);
    g[x].push_back(i);
  }
  dfs(1, -1, 0);
  int q;
  cin >> q;
  while (q--) {
    int type, v;
    cin >> type >> v;
    if (type == 1) {
      int x, k;
      cin >> x >> k;
      update(1, 1, Time, st[v], en[v],
             (x % mod + (1LL * lvl[v] * k) % mod) % mod, 0);
      update(1, 1, Time, st[v], en[v], k % mod, 1);
    } else {
      int ans = query(1, 1, Time, st[v], st[v], lvl[v]);
      cout << ans << endl;
    }
  }
  return 0;
}
