#include <bits/stdc++.h>
#define maxn 300010
using namespace std;

int n, q, a[maxn], c[maxn];
int f[maxn][20], dep[maxn];

int jump(int u)
{
	for (int i = 19; ~i; i -- ) if (a[f[u][i]]) u = f[u][i];
	return u;
}

int main()
{
	scanf("%d%d%d", &q, &a[1], &c[1]);
	dep[1] = 1;
	for (int i = 1; i <= q; i ++ )
	{
		int op, p, A, C, w;
		cin >> op;
		if (op == 1)
		{
			int u = i + 1;
			scanf("%d%d%d", &p, &A, &C), p ++ ;
			a[u] = A, c[u] = C;
			f[u][0] = p, dep[u] = dep[p] + 1;
			for (int t = 1; t < 20; t ++ ) f[u][t] = f[f[u][t - 1]][t - 1];
		}
		else
		{
			scanf("%d%d", &p, &w); p ++ ;
			int ww = w;
			long long ans = 0;
			while (w && a[p] > 0)
			{
				int u = jump(p);
				//cout << u << endl;
				if (a[u] >= w)
				{
					a[u] -= w, ans += 1ll * w * c[u];
					w = 0;
					break;
				}
				else
				{
					w -= a[u];
					ans += 1ll * c[u] * a[u];
					a[u] = 0;
				}
			}
			
			printf("%d %lld\n", ww - w, ans);
		}
	}
	
	return 0;
}