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

#define int long long

template <class type> class SegmentTree{
public:
    int size;
    vector<type> tree;
    type def;
    type (*marge)(type, type);

    SegmentTree(int n, type d, type (*m)(type, type)){
        size = 1;
        def = d;
        marge = m;
        n++;

        while(size < n){
            size *= 2;
        }

        tree.resize(2*size);

        for(int i = 0;i < size;i++){
            tree[size-1+i] = def;
        }

        for(int i = size-2;i >= 0;i--){
            tree[i] = marge(tree[i*2+1], tree[i*2+2]);
        }

        return;
    }

    SegmentTree(int n, type array[], type d, type (*m)(type, type)){
        size = 1;
        def = d;
        marge = m;
        n++;

        while(size < n){
            size *= 2;
        }

        tree.resize(2*size);

        for(int i = 0;i < size;i++){
            if(i < n) tree[size-1+i] = array[i];
            else tree[size-1+i] = def;
        }

        for(int i = size-2;i >= 0;i--){
            tree[i] = marge(tree[i*2+1], tree[i*2+2]);
        }

        return;
    }

    void update(int i, type val){
        i = size-1+i;
        tree[i] = val;

        while(i > 0){
            i = (i-1)/2;
            tree[i] = marge(tree[i*2+1], tree[i*2+2]);
        }

        return;
    }

    void add(int i, type val){
        i = size-1+i;
        tree[i] = tree[i] + val;

        while(i > 0){
            i = (i-1)/2;
            tree[i] = marge(tree[i*2+1], tree[i*2+2]);
        }

        return;
    }

    type get(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return def;
        if(a <= l && r <= b) return tree[k];

        type vl = get(a, b, 2*k+1, l, (l+r)/2);
        type vr = get(a, b, 2*k+2, (l+r)/2, r);

        return marge(vl, vr);
    }

    type get(int a, int b){
        return get(a, b, 0, 0, size);
    }
};

int marge(int a, int b){
    return a + b;
}

#define UP 2000000000

signed main(){
    int q;
    cin >> q;

    vector<int> query;
    vector<int> b;
    vector<pair<int, int> > a;
    vector<pair<int, int> > za;
    for(int p = 0;p < q;p++){
        int x;
        cin >> x;
        query.push_back(x);
        if(x == 1){
            int aa, bb;
            cin >> aa >> bb;
            a.push_back(make_pair(aa + UP, p));
            b.push_back(bb);
            za.push_back(make_pair(aa + UP, p));
        }
    }

    sort(za.begin(), za.end());
    //za.erase(unique(za.begin(), za.end()), za.end());

    SegmentTree<int> seg1(za.size(), 0, marge);
    SegmentTree<int> seg2(za.size(), 0, marge);

    int ap = 0;
    int cnt = 0;
    int ans = 0;
    for(int p = 0;p < q;p++){
        if(query[p] == 1){
            seg1.update(lower_bound(za.begin(), za.end(), a[ap]) - za.begin(), 1);
            seg2.update(lower_bound(za.begin(), za.end(), a[ap]) - za.begin(), a[ap].first);
            ans += b[ap];
            ap++;
            cnt++;
        }else{
            int l = -1;
            int r = za.size();

            while(r - l > 1){
                int mid = (r+l)/2;
                if(seg1.get(0, mid+1) < (cnt+1)/2){
                    l = mid;
                }else{
                    r = mid;
                }
            }

            l = r;

            int tyu = seg2.get(l, l+1);

            int le = tyu * seg1.get(0, l) - seg2.get(0, l);
            int ri = seg2.get(l+1, za.size()) - tyu * seg1.get(l+1, za.size());
            cout << tyu-UP << " " << ans + le + ri << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 20488