#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////
////////////////////////////////////////
// 区間加算区間和
struct RSQRAQ {
    ll n;
    vector<ll> dat, lazy;
    RSQRAQ(){}
    RSQRAQ(ll n_) {
        n = 1; while(n < n_) n *= 2;
        dat.assign(n*2, 0);
        lazy.assign(n*2, 0);
    }
    void eval(ll len, ll k) {
        if(lazy[k] == 0) return;
        if(k*2+1 < n*2-1) {
            lazy[2*k+1] += lazy[k];
            lazy[2*k+2] += lazy[k];
        }
        dat[k] += lazy[k]*len;
        lazy[k] = 0;
    }
    // [a, b)にxを加える
    ll update(ll a, ll b, ll x, ll k, ll l, ll r) {
        eval(r-l, k);
        if(b <= l || r <= a) return dat[k];
        if(a <= l && r <= b) {
            lazy[k] += x;
            return dat[k] + lazy[k]*(r-l);
        }
        return dat[k] = update(a, b, x, 2*k+1, l, (l+r)/2) + update(a, b, x, 2*k+2, (l+r)/2, r);
    }
    ll update(ll a, ll b, ll x) { return update(a, b, x, 0, 0, n); }
    // [a, b)の和を求める
    ll query(ll a, ll b, ll k, ll l, ll r) {
        eval(r-l, k);
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return dat[k];
        ll vl = query(a, b, 2*k+1, l, (l+r)/2);
        ll vr = query(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
    ll query(ll a, ll b) { return query(a, b, 0, 0, n); }
};
//セグ木なので番号は0~n-1
/////////////////////////////////////////


int main(){fastio
    ll q;cin>>q;
    ll a[q][3];
    vector<ll>v;
    rep(i,0,q-1){
        cin>>a[i][0];
        if(a[i][0]==1){
            cin>>a[i][1]>>a[i][2];
            v.pb(a[i][1]);
        }
    }
    ll n=v.size();
    RSQRAQ sum(n),cou(n);
    sort(v.begin(),v.end());
    ll sumb=0;
    ll count=0;
    rep(i,0,q-1){
        
        if(a[i][0]==1){
            sumb+=a[i][2];
            ll pos=lower_bound(v.begin(),v.end(),a[i][1])-v.begin();
            sum.update(pos,pos+1,a[i][1]);
            cou.update(pos,pos+1,1);
            count++;
        }else{
            ll l=0,r=n;
            ll go=(count-1)/2;
            while((r-l)>1){
                ll mid=(l+r)/2;
                if(cou.query(0,mid)<=go){
                    l=mid;
                }else{
                    r=mid;
                }
            }
            ll ans=sumb;
            ans+=sum.query(l,n);
            ans-=cou.query(l,n)*v[l];
            ans+=cou.query(0,l)*v[l];
            ans-=sum.query(0,l);
            cout<<v[l]<<" "<<ans<<endl;
        }
    }
    
    
    return 0;
}




Measured memory_bytes: 23024