#include <bits/stdc++.h>

// my defines
#define fr first
#define sc second
#define pii pair<int, int>
#define pb push_back
#define mk make_pair
#define szof(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define fastInp ios_base::sync_with_stdio(0); cin.tie(0);
#define prev prev132132131231
#define int long long

using namespace std;

const int MAXN = (int)3e5 + 5;
const int L = 20;
int a[MAXN], c[MAXN];

int live[MAXN];
int pr[MAXN][L + 1];

void calc(int v) {
	for (int lv = 1; lv <= L; lv++) {
		pr[v][lv] = pr[pr[v][lv - 1]][lv - 1];
	}
}

signed main() {
	fastInp;
	int q;
	cin >> q >> a[0] >> c[0];
	pr[0][0] = 0;
	calc(0);
	for (int i = 1; i <= q; i++) {
		int type;
		cin >> type;
		if (type == 1) {
			int v, ai, ci;
			cin >> v >> ai >> ci;
			a[i] = ai;
			c[i] = ci;
			pr[i][0] = v;
			calc(i);
		}
		else {
			int v, need_wes;
			cin >> v >> need_wes;
			int cur_cost = 0, cur_wes = 0;
			while (1) {
				if (live[v] == -1) {
					cout << cur_wes << " " << cur_cost << endl;
					break;
				}
				int root = v;
				for (int lv = L; lv >= 0; lv--) {
					if (live[pr[root][lv]] != -1) {
						root = pr[root][lv];
					}
				}
				int count = min(need_wes - cur_wes, a[root]);
				a[root] -= count;
				cur_wes += count;
				cur_cost += count * c[root];
				if (a[root] == 0) {
					live[root] = -1;
				}
				if (cur_wes == need_wes) {
					cout << cur_wes << " " << cur_cost << endl;
					break;
				}
			}
		}
	}
}


/*
5 5 2
2 0 2
1 0 3 4
2 2 4
1 0 1 3
2 4 2
*/
