#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <functional>

struct heavy_light_decomposition {
	using query = std::function<void(int, int)>;
private :
    std::vector<std::vector<int>> g;
    std::vector<int> idx, xdi, par, hvy, head, sz, dep;

    void dfs (int r) {
        std::stack<int> sta; sta.push(r);
        dep[r] = 0; par[r] = -1;
        while (not sta.empty()) {
            int v = sta.top();
            if (not sz[v]) {
                sz[v] = 1;
                for (int u : g[v]) {
                    if (u == par[v]) continue;
                    dep[u] = dep[v] + 1; par[u] = v;
                    sta.push(u);
                }
            } else {
                sta.pop();
                int max_size = 0;
                for (int u : g[v]) if (u != par[v]) {
                    sz[v] += sz[u];
                    if (max_size < sz[u]) {
                        max_size = sz[u];
                        hvy[v] = u;
                    }
                }
            }
        }
    }

    void hld (int r, int &index) {
        std::queue<int> que; que.push(r);
        while (not que.empty()) {
            int h = que.front(); que.pop();
            for (int v = h; v != -1; v = hvy[v]) {
                head[v] = h;
                idx[v] = index++;
                xdi[idx[v]] = v;
                for (int u : g[v]) {
                    if (u != par[v] and u != hvy[v]) {
                        que.push(u);
                    }
                }
            }
        }
    }

public : 

    heavy_light_decomposition (int n) : 
        g(n), idx(n, -1), xdi(n), par(n), hvy(n, -1), head(n), sz(n, 0), dep(n) { }

    void add_edge (int u, int v) noexcept {
        g[u].push_back(v);
        g[v].push_back(u);
    }

    void build () {
        const int n = g.size(); int i = 0;
        for (int v = 0; v < n; v++) if (not sz[v]) dfs(v);
        for (int v = 0; v < n; v++) if (idx[v] == -1) hld(v, i);
    }

    void each_vertex (int u, int v, const query &f) {
        while (true) {
            if (idx[v] < idx[u]) std::swap(u, v);
            if (head[u] == head[v]) {
                f(idx[u], idx[v]);
                break;
            } else {
                f(idx[head[v]], idx[v]);
                v = par[head[v]];
            }
        }
    }

    void each_edge (int u, int v, const query &f) {
        while (true) {
            if (idx[v] < idx[u]) std::swap(u, v);
            if (head[u] == head[v]) {
                if (u != v) f(idx[u] + 1, idx[v]);
                break;
            } else {
                f(idx[head[v]], idx[v]);
                v = par[head[v]];
            }
        }
    }

};


#include <vector>
#include <functional>

template<class T, class E>
struct lazy_segment_tree {
	using F = std::function<T(T, T)>;
	using G = std::function<T(T, E)>;
	using H = std::function<E(E, E)>;
	using value_type = T;
	using operator_type = E;
private : 
	int n, hight;
	F f;
	G g;
	H h;
	value_type ie0;
	operator_type ie1;
	std::vector<value_type> node;
	std::vector<operator_type> lazy;

	constexpr value_type reflect (int i) noexcept {
		return ((lazy[i] == ie1) ? node[i] : g(node[i], lazy[i]));
	}

	void propagate (int i) {
		if (lazy[i] == ie1) return;
		lazy[i << 1 | 0] = h(lazy[i << 1 | 0], lazy[i]);
		lazy[i << 1 | 1] = h(lazy[i << 1 | 1], lazy[i]);
		node[i] = reflect(i);
		lazy[i] = ie1;
	}

	void apply (int i) {
		for (int j = hight; j > 0; j--) {
			propagate(i >> j);
		}
	}

	void recalc (int i) {
		while (i >>= 1) {
			node[i] = f(reflect(i << 1 | 0), reflect(i << 1 | 1));
		}
	}

public : 
	lazy_segment_tree () { }

	lazy_segment_tree (const F &f, const G &g, const H &h, const value_type &ie0, const operator_type &ie1) : 
		f(f), g(g), h(h), ie0(ie0), ie1(ie1) { }

	void reset (const F &f, const G &g, const H &h, const value_type &ie0, const operator_type &ie1) {
		(this->f) = f; (this->g) = g; (this->h) = h;
		(this->ie0) = ie0; (this->ie1) = ie1;
		node.clear(); lazy.clear();
	}

	void assign (int _n) noexcept {
		n = 1; hight = 0;
		while (n < _n) { n <<= 1; hight++; }
		node.assign(2 * n, ie0);
		lazy.assign(2 * n, ie1);
	}

	void assign (int _n, const value_type &e) noexcept {
		assign(_n);
		std::fill(node.begin() + n, node.end(), e);
		for (int i = n; i--> 0;) {
			node[i] = f(node[i << 1 | 0], node[i << 1 | 1]);
		}
	}

	template<class iter>
	void build (iter l, iter r) noexcept {
		assign(r - l);
		for (int i = n; l != r; i++, l++) node[i] = (*l);
		for (int i = n - 1; i > 0; i--) {
			node[i] = f(node[i << 1 | 0], node[i << 1 | 1]);
		}
	}

	void update (int a, int b, const operator_type &x) {
		apply(a + n);
		apply(b + n - 1);
		for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
			if (l & 1) { lazy[l] = h(lazy[l], x); l++; }
			if (r & 1) { r--; lazy[r] = h(lazy[r], x); }
		}
		recalc(a + n);
		recalc(b + n - 1);
	}

	constexpr value_type fold (int l, int r) {
		apply(l + n);
		apply(r + n - 1);
		value_type vl = ie0, vr = ie0;
		for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
			if (l & 1) { vl = f(vl, reflect(l)); l++; }
			if (r & 1) { r--; vr = f(reflect(r), vr); }
		}
		return f(vl, vr);
	}

};


#include <bits/stdc++.h>

int main() {
    std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

    int n;
    std::cin >> n;
    heavy_light_decomposition hld(n);
    for (int v = 0; v < n; v++) {
        int k;
        std::cin >> k;
        while (k--) {
            int u;
            std::cin >> u;
            hld.add_edge(u, v);
        }
    }

    hld.build();

    using node = std::pair<long long, int>;
    auto f = [](const node &l, const node &r) {
        return node(l.first + r.first, l.second + r.second);
    };
    auto g = [](const node &a, const long long &b) {
        return node(a.first + b * a.second, a.second);
    };
    auto h = [](long long a, long long b) {
        return (a + b);
    };
    lazy_segment_tree<node, long long> seg(f, g, h, node(0LL, 0), 0LL);
    seg.assign(n, node(0, 1));

    int q;
    std::cin >> q;
    while (q--) {
        int type;
        std::cin >> type;
        if (type == 0) {
            int v, w;
            std::cin >> v >> w;
            auto add = [&] (int l, int r) -> void {
                seg.update(l, r + 1, w);
            };
            hld.each_edge(0, v, add);
        } else {
            int v;
            std::cin >> v;
            long long ans = 0;
            auto getsum = [&] (int l, int r) -> void {
                ans += seg.fold(l, r + 1).first;
            };
            hld.each_edge(0, v, getsum);
            std::cout << ans << '\n';
        }
    };

    return 0;
}


Measured memory_bytes: 17504