#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;

int MOD = 998244353;
// int MOD = 1000000007;

signed main(){

    ll q;
    cin >> q;
    ll sumb = 0;
    multiset<ll> ls,rs;
    ll ld = 0,rd = 0;
    ls.insert(-INF);
    rs.insert(INF);

    rep(i,q){
        ll qq;
        cin >> qq;
        // for(auto x:ls)cerr << x <<" ";cerr << endl;
        // for(auto x:rs)cerr << x <<" ";cerr << endl;
        // cerr << ld << " " << rd << endl; 
        if(qq == 2){
            ll lmax = *(ls.rbegin());
            ll rmin = *(rs.begin());
            // cerr << "output data : " << rd + ld + sumb + (rmin-lmax)*(rs.size()-1)<< endl << endl;
            cout << *(ls.rbegin()) << " " << rd + ld + sumb + (rmin-lmax)*((int)(rs.size())-1) << "\n";
        }else{
            ll a,b;
            cin >> a >> b;
            sumb += b;
            ll lmax = *(ls.rbegin());
            ll rmin = *(rs.begin());
            if(ls.size() == rs.size()){
                if(a < lmax){
                    ls.insert(a);
                    ld += lmax-a;
                }else if(lmax <= a && a <= rmin){
                    ld += (a-lmax)*(ls.size()-1);
                    ls.insert(a);
                }else if(rmin < a){
                    ld += (rmin-lmax)*(ls.size()-1);
                    ls.insert(rmin);
                    rs.erase(rs.begin());
                    ll new_rmin = *(rs.begin());
                    rd -= (new_rmin - rmin)*(rs.size()-1);
                    if(a <= new_rmin){
                        rd += (new_rmin - a)*(rs.size()-1);
                    }else{
                        rd += (a-new_rmin);
                    }
                    rs.insert(a);
                }
            }else{
                if(rmin <= a){
                    rd += a-rmin;
                    rs.insert(a);
                }else if(lmax <= a && a < rmin){
                    ld += (rmin-a)*(rs.size()-1);
                    rs.insert(a);
                }else{
                    rd += (rmin-lmax)*(rs.size()-1);
                    rs.insert(lmax);
                    auto itr = ls.end();itr--;
                    ls.erase(itr);
                    ll new_lmax = *(ls.rbegin());
                    ld -= (lmax - new_lmax)*(ls.size()-1);
                    if(new_lmax <= a){
                        ld += (a-new_lmax)*(ls.size()-1);
                    }else{
                        ld += (new_lmax-a);
                    }
                    ls.insert(a);
                }
            }
        }
    }

    

    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc127.contest.atcoder.jp/tasks/abc127_f


Measured memory_bytes: 9600