#include "bits/stdc++.h"
using namespace std; 
 
#ifdef LOCAL
    #include "debug.h"
    #define io freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#else
    #define debug(...) 4
    #define io 4
#endif
using ll = long long;
// const int mod = 998244353;
int mod = 1e9 + 7;
const int N = 3e5 + 5;


vector<int> g[N];
int l = 18, timer, level[N];
int tout[N], tin[N], up[N][20];
int a[N], c[N];
void dfs(int v, int p, int d = 0) {
    tin[v] = ++timer;

    for (int u : g[v]) {
        if (u != p) {
            dfs(u, v, d + 1);
        }
    }

    tout[v] = ++timer;
}

bool is_ancestor(int u, int v) {
    return tin[u] <= tin[v] && tout[u] >= tout[v];
}

int lca(int u, int v) {
    if (is_ancestor(u, v))
        return u;
    if (is_ancestor(v, u))
        return v;
    for (int i = l; i >= 0; --i) {
        if (!is_ancestor(up[u][i], v))
            u = up[u][i];
    }
    return up[u][0];
}



signed main() {
    io;
    cin.tie(nullptr) -> sync_with_stdio(false);
    int tc = 1;
    // cin >> tc;
    int tests = 0;
    while(tc--) {   
        int n, x, y;
        cin >> n >> a[0] >> c[0];
        for(int i = 1; i <= n; i++) {
            int type;
            cin >> type;
            if(type == 1) {
                int par, x, cost;
                cin >> par >> x >> cost;
                up[i][0] = par;
                c[i] = cost;
                a[i] = x;
                for (int j = 1; j <= l; ++j)
                    up[i][j] = up[up[i][j -  1]][j - 1];

            }
            else {
                int v, need;
                cin >> v >> need;
                int ton = 0;
                ll cost = 0;
                while(need > 0 && a[v] > 0) {
                    int topmost_node = v;
                    for(int j = l; j >= 0; j--) {
                        if(a[up[topmost_node][j]] > 0)
                            topmost_node = up[topmost_node][j];
                    }
                    int mn = min(a[topmost_node], need);
                    a[topmost_node] -= mn;
                    need -= mn;
                    ton += mn;
                    cost += 1ll * mn * c[topmost_node];
                }
                cout << ton << " " << cost; 
                cout << endl;
                // fflush(stdout);

            }
        }
    }


     
}   

