//#include<bits/stdc++.h>
#include <iostream>
#include<string>
#include <algorithm>
#include <vector>
#include<iomanip>
#include<random>
#include <stack>
#include <map>
#include <set>
#include <cstring>
#define ll long long
#define ld long double
#define F first
#define S second
#define Tsetso ios_base::sync_with_stdio(0) ; cin.tie(0) ;
#define Read freopen("minmax.in","r",stdin);
using namespace std;
const int N = 3e5+10 , mod = 1e9+7 , length = 25;
ll q  ,ancestor[N][30],a[N],c[N],lvl[N],sum = 0;
vector < int > g[N];
void add( int node , int  par )
{
    lvl[node] = lvl[par]+1;
    ancestor[node][0] = par;
    for ( int i = 1 ; i <= 25; i++)
        ancestor[node][i] = ancestor[ancestor[node][i - 1]][i - 1];
}
int  get_kthparent( int  u , int k )
{
    for ( int  i = length-1 ; i >= 0 ; i--)
        if ( (k >> i) & 1)
            u = ancestor[u][i];
    return u;
}

int lca( int u , int  v)
{
    if ( lvl[u] > lvl[v])
        swap(u,v);
    v = get_kthparent(v,lvl[v]-lvl[u]);
    if ( u == v)
        return v ;
    for ( int  i = length-1 ; i >= 0 ; i--)
    {
        if ( ancestor[u][i] != ancestor[v][i])
            u = ancestor[u][i], v = ancestor[v][i];
    }
    return ancestor[u][0];
}
void dfs( int node , int child , ll &w )
{
    ll mn = min(a[node],w);
    sum += mn * c[node];
    a[node] -= mn ;
    w -= mn ;
    if ( w == 0)
            return ;
    for ( auto i  :g[node])
        if ( lca(child,i) == i)
            dfs(i,child,w);
}
int main()
{
    Tsetso
    cin >> q  >> a[0] >> c[0];
    for ( int i = 1 ; i <= q ; i++)
    {
        int type ;
        cin >> type ;
        if ( type == 1)
        {
            int p ;
            cin >> p >> a[i] >> c[i];
            g[p].push_back(i);
            add(i,p);
        }
        else
        {
            ll u , w ;
            cin >> u >> w ;
            ll node  = u , W =  w;
            for ( int i =length ; i >= 0 ; i--)
            {
                if ( a[ancestor[node][i]] > 0)
                        node = ancestor[node][i];
            }
            sum = 0 ;
            dfs(node,u,w);
            cout << W - w << ' ' << sum << endl;
        }
    }
}