#include <limits>
#include <initializer_list>
#include <utility>
#include <bitset>
#include <tuple>
#include <type_traits>
#include <functional>
#include <string>
#include <array>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <algorithm>
#include <complex>
#include <random>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <regex>
#include <cassert>
#include <cstddef>
// #include <variant>

// Yay!!
#define endl codeforces

// macros for iterator
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)

// alias
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;

// variadic min/max
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }

// variadic chmin/chmax
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

// multi demension array
template <typename T, std::size_t Head, std::size_t... Tail> struct multi_dim_array { using type = std::array<typename multi_dim_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dim_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t... Args> using mdarray = typename multi_dim_array<T, Args...>::type;

// fill container
// template <typename T, typename F, typename... Args> 
// void fill_seq(T &t, F f, Args... args) { if constexpr (std::is_invocable<F, Args...>::value) { t = f(args...); } else { for (ssize_t i = 0; i < t.size(); i++) fill_seq(t[i], f, args..., i); } }

// make multi dimension vector
template <typename T> vec<T> make_v(ssize_t sz) { return vec<T>(sz); }
template <typename T, typename... Tail> auto make_v(ssize_t hs, Tail&&... ts) { auto v = std::move(make_v<T>(std::forward<Tail>(ts)...)); return vec<decltype(v)>(hs, v); }

// init
namespace init__ { 
struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; 
}


namespace tree {

template <typename Key>
struct splay_node {
    using node_ptr = splay_node<Key>*;
    using size_type = ssize_t;

    Key key;
    node_ptr l, r, p;
    size_type sz;

    splay_node(Key key, node_ptr l, node_ptr r, node_ptr p) : key(key), l(l), r(r), p(p), sz(1) { }
    splay_node(Key key) : splay_node(key, nullptr, nullptr, nullptr) { }
    splay_node() : splay_node(Key()) { }

    bool is_root() const {
        return !p;
    }

    void update() {
        sz = 1;
        if (l) {
            sz += l->sz;
            l->p = this;
        }
        if (r) {
            sz += r->sz;
            r->p = this;
        }
    }
};

template <typename Node>
bool is_l(const Node *n) {
    return !n->is_root() && n->p->l == n;
}

/*
 * - counter clock wise
 *    p             x
 *   / \           / \
 *  a   x    ->   p   c
 *     / \       / \
 *    b   c     a   b
 *
 * - clock wise
 *      p           x         
 *     / \         / \
 *    x   c  ->   a   p 
 *   / \             / \
 *  a   b           b   c     
 *
 */
template <typename Node>
void rotate(Node *n, bool cc) {
    auto x = n, p = n->p;
    auto pp = p->p;
    Node *a, *b, *c;
    bool rp = p->is_root();  // for lctree
    bool ppl = is_l(p);
    if (cc) {
        a = p->l; b = x->l; c = x->r;
        x->l = p; x->r = c; x->p = pp;
        p->l = a; p->r = b; p->p = x;
        if (pp && !rp) {
            if (ppl) pp->l = x;
            else pp->r = x;
        }
    } else {
        a = x->l; b = x->r; c = p->r;
        x->l = a; x->r = p; x->p = pp;
        p->l = b; p->r = c; p->p = x;
        if (pp && !rp) {
            if (ppl) pp->l = x;
            else pp->r = x;
        }
    }
    p->update();
    x->update();
    if (pp) pp->update();
}

template <typename Node>
void zig(Node *n) {
    rotate(n, !is_l(n));
}

template <typename Node>
void zig_zig(Node *n) {
    bool wise = !is_l(n);
    rotate(n->p, wise);
    rotate(n, wise);
}

template <typename Node>
void zig_zag(Node *n) {
    bool wise = !is_l(n);
    rotate(n, wise);
    rotate(n, !wise);
}

template <typename Node>
void splay_aux(Node *n) {
    auto p = n->p;
    if (!p) return;
    if (p->is_root()) {
        zig(n);
        return;
    }
    bool a = is_l(n);
    bool b = is_l(p);
    if (a == b) zig_zig(n);
    else zig_zag(n);
}

template <typename Node>
void splay(Node *n) {
    while (!n->is_root()) splay_aux(n);
}

template <typename Key, typename Comp>
struct SplayTree {
    using node = splay_node<Key>;
    using size_type = typename node::size_type;
    using node_ptr = typename node::node_ptr;

    node_ptr root;
    Comp comp;

    SplayTree(node_ptr root = nullptr) : root(root) { }

    void splay(node_ptr n) {
        splay(n);
        root = n;
    }

    node_ptr find(Key key) {
        node_ptr cur = root;
        while (cur) {
            if (cur->key == key) break;
            if (comp(key, cur->key)) {
                if (!cur->l) break;
                cur = cur->l;
            } else {
                if (!cur->r) break;
                cur = cur->r;
            }
        }
        this->splay(cur);
        if (cur->key != key) return nullptr;
        else return cur;
    }

    node_ptr insert(Key key) {
        if (root == nullptr) return root = new node(key);
        find(key);
        if (root->key == key) return root;
        node_ptr n = new node(key);
        if (comp(root->key, key)) {
            root->p = n;
            n->l = root;
            n->r = root->r;
            root->r = nullptr;
        } else {
            root->p = n;
            n->l = root->l;
            n->r = root;
            root->l = nullptr;
        }
        if (n->l) n->l->update();
        if (n->r) n->r->update();
        n->update();
        root = n;
        return root;
    }

    void erase(node_ptr n) {
        if (!n) return;
        this->splay(n);
        node_ptr l = root->l, r = root->r;
        n->l = n->r = nullptr;
        if (l) l->p = nullptr;
        if (r) r->p = nullptr;
        if (!l && !r) {
            root = nullptr;
        } else if (!l) {
            root = r;
        } else if (!r) {
            root = l;
        } else {
            SplayTree tmp(r);
            tmp.find(l->key);
            node_ptr rmin = tmp.root;
            rmin->l = l;
            rmin->update();
            root = rmin;
        }
        if (root) root->update();
        delete n;
    }

    void erase(Key key) {
        node_ptr n = find(key);
        erase(n);
    }

    node_ptr operator [](size_type idx) {
        size_type sz = idx + 1;
        node_ptr cur = root;
        while (true) {
            size_type lsz = (cur->l ? cur->l->sz : 0);
            size_type ord = lsz + 1;
            if (sz == ord) {
                break;
            } else if (sz < ord) {
                cur = cur->l;
            } else {
                sz -= ord;
                cur = cur->r;
            }
        }
        this->splay(cur);
        return root;
    }
};

}

namespace tree {

namespace lctree {

template <typename M, typename Op>
struct link_cut_node {
    using node_ptr = link_cut_node<M, Op>*;
    using size_type = ssize_t;
    node_ptr l, r, p;
    size_type sz;
    M m, sum = M::id_ele(), rsum = M::id_ele();
    Op op = Op::id_ele();
    bool rev, lazy;
    ll i__;

    link_cut_node(node_ptr p, node_ptr l, node_ptr r, M m, ll i) 
        : p(p), l(l), r(r), sz(1), m(m), rev(false), lazy(false), i__(i) { }
    link_cut_node() 
        : link_cut_node(nullptr, nullptr, nullptr, M::id_ele()) { }

    bool is_root() const {
        return !p || (p->l != this && p->r != this);
    }

    void init_lazy() {
        lazy = false;
        op = Op::id_ele();
    }

    void update() {
        sz = 1;
        sum = m;
        rsum = m;
        if (l) {
            sum = M::merge(l->sum, sum);
            rsum = M::merge(rsum, l->rsum);
            sz += l->sz;
            l->p = this;
        }
        if (r) {
            sum = M::merge(sum, r->sum);
            rsum = M::merge(r->rsum, rsum);
            sz += r->sz;
            r->p = this;
        }
    }
};

template <typename M, typename Op>
void propagate(link_cut_node<M, Op> *n, const Op op) {
    n->lazy = true;
    n->op = Op::merge(n->op, op);
    n->m.apply(op);
    n->sum.apply(op);
    n->rsum.apply(op);
}

template <typename M, typename Op>
void toggle(link_cut_node<M, Op> *n) {
    std::swap(n->l, n->r);
    n->update();
    n->rev ^= true;
}

template <typename M, typename Op>
void push(link_cut_node<M, Op> *n) {
    if (n->lazy) {
        for (auto c : { n->l, n->r }) if (c) propagate(c, n->op);
        n->init_lazy();
    }
    if (n->rev) {
        if (n->l) toggle(n->l);
        if (n->r) toggle(n->r);
        n->rev = false;
    }
}

template <typename M, typename Op>
void splay(link_cut_node<M, Op> *n) {
    push(n);
    while (!n->is_root()) {
        auto p = n->p;
        if (p->p) push(p->p);
        push(p);
        push(n);
        tree::splay_aux(n);
    }
}

template <typename M, typename Op>
struct LinkCutTree {
    /*
     * TODO
    static_assert(utility::is_monoid<M>::value, "M must be monoid.");
    static_assert(utility::is_monoid<Op>::value, "Op must be monoid.");
    static_assert(utility::enable_apply<M, Op>::value, "Op is not operator of M.");
    */
    
    using node_type = link_cut_node<M, Op>;
    using node_ptr = node_type*;
    using size_type = typename node_type::size_type;

    template <typename F>
    LinkCutTree(F f, size_type sz) : nodes(sz) {
        for (size_type i = 0; i < sz; i++) {
             nodes[i] = new node_type(nullptr, nullptr, nullptr, f(i), i);
        }
    }

    node_ptr expose(size_type idx) {
        node_ptr r = nullptr;
        for (node_ptr cur = nodes[idx]; cur; cur = cur->p) {
            splay(cur);
            cur->r = r;
            cur->update();
            r = cur;
        }
        auto ret = nodes[idx];
        splay(ret);
        return ret;
    }

    void link(size_type p, size_type c) {
        auto pp = expose(p);
        auto cp = expose(c);
        cp->p = pp;
        pp->r = cp;
        pp->update();
    }

    void cut(size_type idx) {
        auto p = expose(idx);
        auto lp = p->l;
        p->l = nullptr;
        p->update();
        lp->p = nullptr;
    }

    void evert(size_type idx) {
        auto p = expose(idx);
        toggle(p);
        push(p);
    }

    void apply(size_type idx, Op op) {
        auto p = expose(idx);
        propagate(p, op);
        push(p);
    }

private:
    vec<node_ptr> nodes;
};

}

}

struct Op {
    ll v;

    Op(ll v) : v(v) { }

    static Op id_ele() {
        return Op(0);
    }

    static Op merge(const Op &o1, const Op &o2) {
        return Op(o1.v + o2.v);
    }
};

struct M {
    ll v, sz;

    M(ll v, ll sz = 1) : v(v), sz(sz) { }

    static M id_ele() {
        return M(0, 0);
    }

    static M merge(const M &m1, const M &m2) {
        return M(m1.v + m2.v, m1.sz + m2.sz);
    }

    void apply(const Op &o) {
        v += sz * o.v;
    }
};

int main() {
    ll n;
    std::cin >> n;

    tree::lctree::LinkCutTree<M, Op> lct([&](int) { return M(0, 1); }, n);

    for (ll i = 0; i < n; i++) {
        ll k;
        std::cin >> k;
        while (k--) {
            ll c;
            std::cin >> c;
            lct.link(i, c);
        }
    }

    ll q;
    std::cin >> q;
    while (q--) {
        ll t;
        std::cin >> t;
        if (t == 0) {
            ll v, w;
            std::cin >> v >> w;
            lct.apply(v, w);
            lct.apply(0, -w);
        } else {
            ll v;
            std::cin >> v;
            auto p = lct.expose(v);
            std::cout << p->sum.v << "\n";
        }
    }
    return 0;
}



Measured memory_bytes: 14780