#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T>
class SegmentTree{
    int n;
    int realsize;
    T initialvalue;
    vector<T> tree;

    public:
    
    SegmentTree(int size,T initial):realsize(size),initialvalue(initial){
        n = 1;
        while(n < size)n *= 2;

        tree = vector<T>(2*n + 1,initial);
    }

    //1-indexed
    void insert(int i,T data){
        int ind = n+i-1;
        tree[ind] = data;
        ind >>= 1;
        while(ind > 0){
            tree[ind] = tree[ind*2] + tree[ind*2+1];
            ind >>= 1;
        }
    }

    void add(int i,T data){
        int ind = n+i-1;
        tree[ind] += data;
        ind >>= 1;
        while(ind > 0){
            tree[ind] = tree[ind*2] + tree[ind*2+1];
            ind >>= 1;
        }
    }

    T get(int l,int r){
        if(l > realsize || r > realsize || l <= 0 || r <= 0)return initialvalue;
        l = n+l-1;
        r = n+r-1;
        if(l == r)return tree[l];
        int prel = l;
        int prer = r;
        T lnum = tree[l];
        T rnum = tree[r];
        l >>= 1;
        r >>= 1;
        while(l != r){
            if(l*2 == prel){
                lnum += tree[l*2+1];
            }
            if(r*2+1 == prer){
                rnum += tree[r*2];
            }
            prel = l;
            prer = r;
            l >>= 1;
            r >>= 1;
        }
        return lnum+rnum;
    }
};

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

    vector<ll> a,b,req;
    a.push_back(0);
    b.push_back(0);

    for(int i = 0; i < q; i++){
        ll t;
        cin >> t;
        if(t == 1){
            ll x,y;
            cin >> x >> y;
            a.push_back(x);
            b.push_back(y);
        }else{
            req.push_back(a.size());
        }
    }

    vector<ll> ca = a;
    vector<ll> sumb(b.size(),0);
    for(int i = 1; i < b.size(); i++){
        sumb[i] = sumb[i-1] + b[i];
    }

    sort(ca.begin()+1,ca.end());

    SegmentTree<ll> st(a.size(),0),st2(a.size(),0);

    vector<ll> ansval(a.size()),ansx(a.size());

    for(int i = 1; i < a.size(); i++){
        auto itr = lower_bound(ca.begin()+1,ca.end(),a[i]);
        st.add(itr - ca.begin(),1);
        st2.add(itr - ca.begin(),a[i]);
        ll needNum = (i+1)/2;
        ll ok = a.size()-1;
        ll ng = 0;
        while(abs(ok - ng) > 1){
            ll middle = (ok + ng)/2;
            if(st.get(1,middle) >= needNum){
                ok = middle;
            }else{
                ng = middle;
            }
        }
        ansx[i] = ca[ok];
        ansval[i] = (st.get(1,ok-1)*ansx[i] - st2.get(1,ok-1)) + (st2.get(ok+1,a.size()) - st.get(ok+1,a.size())*ansx[i]) + sumb[i];
    }

    for(int i = 0; i < req.size(); i++){
        cout << ansx[req[i]-1] << " ";
        cout << ansval[req[i]-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 18020