#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long

using namespace std;

const int INF = (int) 1e9 + 4;

struct Data {
    int x, y, ind;

    bool operator< (const Data &other) const {
        return x < other.x;
    }
};


struct AINT_MED {
    vector<int> aint;

    AINT_MED(int sz) {
        aint.resize(4 * sz + 5, 0);
    }

    void update(int pos, int node, int le, int ri) {
        if(le == ri)
            aint[node] ++;
        else {
            int mid = (le + ri) / 2;
            if(pos <= mid)
                update(pos, node * 2, le, mid);
            else
                update(pos, node * 2 + 1, mid + 1, ri);
            aint[node] = (aint[node * 2] + aint[node * 2 + 1]);
        }
    }

    int query(int nr, int node, int le, int ri) {
        if(le == ri)
            return le;
        else {
            int mid = (le + ri) / 2;
            if(nr <= aint[node * 2])
                return query(nr, node * 2, le, mid);
            else
                return query(nr - aint[node * 2], node * 2 + 1, mid + 1, ri);
        }
    }

    int query2(int from, int to, int node, int le, int ri) {
        if(from > to)
            return 0;

        if(from <= le & ri <= to)
            return aint[node];
        else {
            int mid = (le + ri) / 2;
            int ans = 0;
            if(from <= mid)
                ans += query2(from, to, node * 2, le, mid);
            if(mid < to)
                ans += query2(from, to, node * 2 + 1, mid + 1, ri);
            return ans;
        }
    }
};

struct AINT_SUM {
    vector<ll> aint;

    AINT_SUM(int sz) {
        aint.resize(4 * sz + 1, 0);
    }

    void update(int pos, int val, int node, int le, int ri) {
        if(le == ri)
            aint[node] += 1LL * val;
        else {
            int mid = (le + ri) / 2;
            if(pos <= mid)
                update(pos, val, node * 2, le, mid);
            else
                update(pos, val, node * 2 + 1, mid + 1, ri);
            aint[node] = aint[node * 2] + aint[node * 2 + 1];
        }
    }

    ll query(int from, int to, int node, int le, int ri) {
        if(from > to)
            return 0;
        if(from <= le && ri <= to)
            return aint[node];
        int mid = (le + ri) / 2;
        ll ans = 0;
        if(from <= mid)
            ans += query(from, to, node * 2, le, mid);
        if(mid < to)
            ans += query(from, to, node * 2 + 1, mid + 1, ri);
        return ans;
    }
};



int main() {
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int q;
    cin >> q;
    vector<Data> v(q + 1, {INF, INF});
    for(int i = 1; i <= q; i ++) {
        int type, a = INF, b = INF;
        cin >> type;
        if(type == 1)
            cin >> a >> b;
        v[i] = {a, b, i};
    }
    vector<Data> auxv = v;
    sort(v.begin() + 1, v.end());

    vector<int> pos(q + 1, 0);
    vector<int> val(q + 1, 0);
    for(int i = 1; i <= q; i ++) {
        if(v[i].x == v[i - 1].x)
            pos[v[i].ind] = pos[v[i - 1].ind];
        else {
            pos[v[i].ind] = i;
            val[i] = v[i].x;
        }
    }

    v = auxv;
    ///pt primul aint tb sa return val[query];
    AINT_MED med(q + 1);
    AINT_SUM sum(q + 1);
    ll bsum = 0;
    int cnt = 0;

    for(int i = 1; i <= q; i ++) {
        if(v[i].y != INF) {
            bsum += v[i].y;
            med.update(pos[i], 1, 1, q);
            sum.update(pos[i], v[i].x, 1, 1, q);
            cnt ++;
        } else {
            int x = med.query((cnt + 1) / 2, 1, 1, q);
            ll small = sum.query(1, x - 1, 1, 1, q);
            ll big = sum.query(x + 1, q, 1, 1, q);

            ll ans = 1LL * med.query2(1, x - 1, 1, 1, q) * val[x] - small + big - 1LL * med.query2(x + 1, q, 1, 1, q) * val[x] + bsum;

            cout << val[x] << " " << ans << "\n";
        }

    }

    return 0;
}


Measured memory_bytes: 18560