#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
//using namespace atcoder;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}


const ll INF=1e18;
const int mx=200005;

class Segtree{
public:
    ll N=1;
    V<ll> dat;
    explicit Segtree(ll sz){
        while(N<sz) N*=2;
        dat.reserve(2*N);
        rep(i,2*N)dat[i]=0;
    }

    // Range Minimum Query -------------------------

    void min_init(){
        for(int i=0;i<N;i++)min_update(i,INF);
    }

    void min_update(ll k,ll a){
        k+=N-1;
        dat[k]=a;
        while(k>0){
            k=(k-1)/2;
            dat[k]=min(dat[2*k+1],dat[2*k+2]);
        }
    }

    ll min_query(ll a,ll b,ll k,ll l,ll r){
        if(r<=a||b<=l)return INF;
        if(a<=l&&r<=b)return dat[k];
        ll m=(l+r)/2;
        ll u=min_query(a,b,2*k+1,l,m);
        ll v=min_query(a,b,2*k+2,m,r);
        return min(u,v);
    }

    ll get_min(ll l,ll r){
        return min_query(l,r,0,0,N);
    }

    //Range Maximum Query ---------------------------

    void max_init(){
        for(int i=0;i<N;i++)max_update(i,-INF);
    }

    void max_update(ll k,ll a){
        k+=N-1;
        dat[k]=a;
        while(k>0){
            k=(k-1)/2;
            dat[k]=max(dat[2*k+1],dat[2*k+2]);
        }
    }

    ll max_query(ll a,ll b,ll k,ll l,ll r){
        if(r<=a||b<=l)return -INF;
        if(a<=l&&r<=b)return dat[k];
        ll m=(l+r)/2;
        ll u=max_query(a,b,2*k+1,l,m);
        ll v=max_query(a,b,2*k+2,m,r);
        return max(u,v);
    }

    ll get_max(ll l,ll r){
        return max_query(l,r,0,0,N);
    }

    //Range Sum Query -----------------------------

    void sum_update(ll k,ll a){
        k+=N-1;
        dat[k]+=a;
        while(k>0){
            k=(k-1)/2;
            dat[k]=(dat[2*k+1]+dat[2*k+2]);
        }
    }
    
    ll sum_query(ll a,ll b,ll k,ll l,ll r){
        if(r<=a||b<=l)return 0LL;
        if(a<=l&&r<=b)return dat[k];
        ll m=(l+r)/2;
        ll u=sum_query(a,b,2*k+1,l,m);
        ll v=sum_query(a,b,2*k+2,m,r);
        return (u+v);
    }

    ll get_sum(ll l,ll r){
        return sum_query(l,r,0,0,N);
    }

    //その他----------------------------------------
    /*
    ll unit(){
        return ;//単位元
    }
    ll calc(ll a,ll b){
        return ;//演算
    }
    void update(ll k,ll a){
        k+=N-1;
        dat[k]=a;
        while(k>0){
            k=(k-1)/2;
            dat[k]=calc(dat[2*k+1],dat[2*k+2]);
        }
    }
    ll query(ll a,ll b,ll k,ll l,ll r){
        if(r<=a||b<=l)return unit();
        if(a<=l&&r<=b)return dat[k];
        ll m=(l+r)/2;
        ll u=min_query(a,b,2*k+1,l,m);
        ll v=min_query(a,b,2*k+2,m,r);
        return calc(u,v);
    }
    */
};


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int Q;
    cin>>Q;
    V<ll> op(Q),a(Q),b(Q);
    set<ll> st;
    ll sum=0;
    rep(i,Q){
        cin>>op[i];
        if(op[i]==1){
            cin>>a[i]>>b[i];
            st.insert(a[i]);
        }
    }
    ll sz=st.size();
    Segtree s1(sz),s2(sz);
    V<ll> to(sz);
    map<ll,ll> mp;
    int k=0;
    for(auto it=st.begin();it!=st.end();it++){
        to[k]=*it;
        mp[*it]=k;
        k++;
    }
    rep(i,Q){
        if(op[i]==1){
            sum+=b[i];
            int pos=mp[a[i]];
            s1.sum_update(pos,1LL);
            s2.sum_update(pos,a[i]);
        }else{
            ll l=-1,r=sz;
            ll tmp=(s1.get_sum(0,sz)+1)/2;
            while(r-l>1){
                ll mid=(l+r)/2;
                if(s1.get_sum(0,mid+1)>=tmp) r=mid;
                else l=mid;
            }
            ll ans=sum;
            ans+=s1.get_sum(0,r)*to[r]-s2.get_sum(0,r);
            ans+=-s1.get_sum(r+1,sz)*to[r]+s2.get_sum(r+1,sz);
            //cout<<r<<endl;
            cout<<to[r]<<' '<<ans<<'\n';
        }
    }
}

Measured memory_bytes: 23768