#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

struct SegmentTree {
  using T = pair<lint, int>;
  static T op(const T& x, const T& y) { return {x.first + y.first, x.second + y.second}; }
  static constexpr T e() { return {0, 0}; }
  using U = lint;
  static void ap(const U& f, T& x) { x.first += f * x.second; }
  static void cp(const U& g, U& f) { f += g; }
  static constexpr U id() { return 0; }

  const int n;
  V<T> t;
  V<U> u;
  SegmentTree(int n) : n(n), t(2 * n, e()), u(n, id()) {}
  T& operator[](int i) { return t[i + n]; }
  void build() { for (int i = n - 1; i; --i) t[i] = op(t[2 * i], t[2 * i + 1]); }
  void push() { for (int i = 1; i < n; ++i) push(i); }
  void apply(const U& f, int i) {
    ap(f, t[i]);
    if (i < n) cp(f, u[i]);
  }
  void push(int i) {
    if (u[i] == id()) return;
    apply(u[i], 2 * i);
    apply(u[i], 2 * i + 1);
    u[i] = id();
  }
  void push(int l, int r) {
    for (int hl = __lg(l + n), hr = __lg(r - 1 + n); hr > 0; --hl, --hr) {
      int al = l + n >> hl, ar = r - 1 + n >> hr;
      if (al < n) push(al);
      if (ar != al) push(ar);
    }
  }
  T acc(int l, int r) {
    push(l, r);
    T resl = e(), resr = e();
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) resl = op(resl, t[l++]);
      if (r & 1) resr = op(t[--r], resr);
    }
    return op(resl, resr);
  }
  T get(int i) { return acc(i, i + 1); }
  void act(int l, int r, const U& f) {
    push(l, r);
    for (int i = l + n, j = r + n; i < j; i >>= 1, j >>= 1) {
      if (i & 1) apply(f, i++);
      if (j & 1) apply(f, --j);
    }
    l = l + n >> __builtin_ctz(l + n);
    while (l >>= 1) t[l] = op(t[2 * l], t[2 * l + 1]);
    r = r + n >> __builtin_ctz(r + n);
    while (r >>= 1) t[r] = op(t[2 * r], t[2 * r + 1]);
  }
  void set(int i, const T& x) {
    push(i, i + 1);
    t[i += n] = x;
    while (i >>= 1) t[i] = op(t[2 * i], t[2 * i + 1]);
  }
};

// BEGIN CUT HERE
// 部分木vは[in[v],out[v])に対応
// TODO: 非可換
struct HeavyLightDecomposition {
  const bool edge;
  const int n;
  VV<> g;
  V<> sz, par, in, out, anc, rev;
  HeavyLightDecomposition(VV<>& g, bool edge, int r = 0) :
    edge(edge), n(g.size()), g(g), sz(n), par(n), in(n), out(n), anc(n), rev(n) {
    dfs_sz(r, -1);
    anc[r] = r;
    dfs_hl(r);
  }
  void dfs_sz(int v, int p) {
    par[v] = p;
    for (auto&& w : g[v]) if (w == p) {
      swap(w, g[v].back());
      g[v].pop_back();
      break;
    }
    sz[v] = 1;
    for (auto&& w : g[v]) {
      dfs_sz(w, v);
      sz[v] += sz[w];
      if (sz[w] > sz[g[v][0]]) swap(w, g[v][0]);
    }
  }
  void dfs_hl(int v) {
    static int t = 0;
    in[v] = t++;
    rev[in[v]] = v;
    for (int w : g[v]) {
      anc[w] = w == g[v][0] ? anc[v] : w;
      dfs_hl(w);
    }
    out[v] = t;
  }
  int lca(int u, int v) const {
    while (true) {
      if (in[u] > in[v]) swap(u, v);
      if (anc[u] == anc[v]) return u;
      v = par[anc[v]];
    }
  }
  auto acc(SegmentTree& st, int u, int v) const {
    auto res = st.e();
    while (true) {
      if (in[u] > in[v]) swap(u, v);
      if (anc[u] == anc[v]) break;
      res = st.op(res, st.acc(in[anc[v]], in[v] + 1));
      v = par[anc[v]];
    }
    res = st.op(res, st.acc(in[u] + edge, in[v] + 1));
    return res;
  }
  void act(SegmentTree& st, int u, int v, const SegmentTree::U& f) const {
    while (true) {
      if (in[u] > in[v]) swap(u, v);
      if (anc[u] == anc[v]) break;
      st.act(in[anc[v]], in[v] + 1, f);
      v = par[anc[v]];
    }
    st.act(in[u] + edge, in[v] + 1, f);
  }
};
// END CUT HERE

template<class Z> Z rng(Z a, Z b) {
  static mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
  return uniform_int_distribution<Z>(a, b - 1)(mt);
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  VV<> g(n);
  for (int v = 0; v < n; ++v) {
    int k; cin >> k;
    while (k--) {
      int c; cin >> c;
      g[v].push_back(c);
      g[c].push_back(v);
    }
  }
  HeavyLightDecomposition hld(g, true, rng(0, n));
  SegmentTree st(n);
  for (int i = 0; i < n; ++i) {
    st[i] = {0, 1};
  }
  st.build();
  int q; cin >> q;
  while (q--) {
    int tp; cin >> tp;
    if (!tp) {
      int v, w; cin >> v >> w;
      hld.act(st, 0, v, w);
    } else {
      int v; cin >> v;
      cout << hld.acc(st, 0, v).first << '\n';
    }
  }
}


Measured memory_bytes: 24176