#include <bits/stdc++.h>

using namespace std;

const int N = 3e5 + 100;
const int K = 19;
int LCA[N][K], remain[N], c[N], p[N], h[N];

void Solve() {
    int q, a0, c0;
    int n = 1;
    cin >> q >> remain[1] >> c[1];    
    map<int, int> mapping;
    mapping[0] = 1;
    for (int i = 1; i <= q; ++i) {
        int type;
        cin >> type;
        if (type == 1) {
            ++n;
            mapping[i] = n;
            cin >> p[n] >> remain[n] >> c[n];
            // ++p[n];
            p[n] = mapping[p[n]];
            h[n] = h[p[n]] + 1;
            LCA[n][0] = p[n];
            for (int i = 1; i < K; ++i) LCA[n][i] = LCA[LCA[n][i - 1]][i - 1];
        } else {
            int v, w;
            cin >> v >> w;
            v = mapping[v];
            long long spent = 0;
            int bought = 0;
            // cerr << "remain " << v << ' ' << remain[v] << ' ' << w << '\n';
            while (w && remain[v]) {
                int root = v;
                for (int i = K - 1; i >= 0; --i) if (remain[LCA[root][i]]) root = LCA[root][i];
                // cerr << "remain " << remain[root] << ' ' << c[root] << ' ' << w << '\n';
                int took = min(w, remain[root]);
                spent += 1ll * took * c[root];
                remain[root] -= took;
                w -= took;
                bought += took;
            }
            cout << bought << ' ' << spent << endl;
        }
    }
}

int main() {
    int test = 1;
    // cin >> test;
    while (test--) Solve();
}