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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

typedef pair<ll, pll> plll;

template<class V, int ME> class BIT {
public:
    V bit[1<<ME];
    V total(int e) {V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;}
    void add(int e, V val) {e++; while(e<=1<<ME) bit[e-1]+=val,e+=e&-e;}
};

BIT<ll, 18> bit1, bit2;
const ll MA = (1ll << 18)-1;

map<ll,ll> zip;
ll unzip[MA];

ll compress(vector<ll> &x) {
    sort(x.begin(), x.end());
    x.erase(unique(x.begin(),x.end()),x.end());
    for(ll i = 0; i < x.size(); i++){
        zip[x[i]] = i;
        unzip[i] = x[i];
    }
    return x.size();
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    REP(i, MA) bit1.bit[i] = 0;
    REP(i, MA) bit2.bit[i] = 0;

    ll Q;
    cin >> Q;
    vector<plll> queries;
    vector<ll> as;
    REP(i, Q){
        ll q;
        cin >> q;
        if(q == 1){
            ll a, b;
            cin >> a >> b;
            as.push_back(a);
            queries.push_back({1, {a, b}});
        }else{
            queries.push_back({2, {-1, -1}});
        }
    }
    compress(as);

    ll B = 0;
    ll cnt = 0;
    REP(i, Q){
        auto query = queries[i];
        if(query.first == 1){
            ll a = query.second.first;
            ll b = query.second.second;
            B += b;
            ll a_comp = zip[a];
            bit1.add(a_comp, 1);

            /*
            dump(bit1.total(MA-1))
            cout << bit1.total(0) << " ";
            REP(i, 10) cout << bit1.total(i+1) - bit1.total(i) << " ";
            cout << endl;
            */

            bit2.add(a_comp, a);

            /*
            dump(bit1.total(MA-1))
            cout << bit1.total(0) << " ";
            REP(i, 10) cout << bit1.total(i+1) - bit1.total(i) << " ";
            cout << endl;
            */
            cnt++;
        }else{
            ll lb = -1, ub = MA; //?
            while(ub-lb>1){
                ll mid = (lb+ub)/2;
                bool ok;
                ll sum = bit1.total(mid);
                ok = (sum >= (cnt+1)/2);
                if(ok){
                    ub = mid;
                }else{
                    lb = mid;
                }
            }
            ll med = ub;
            ll med_x = unzip[med];

            ll res = 0;
            res -= bit2.total(med);
            res += med_x * bit1.total(med);

            res += (bit2.total(MA) - bit2.total(med));
            res -= med_x * (bit1.total(MA) - bit1.total(med));

            res += B;

            cout << med_x << " " << res << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 20012