#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <utility>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

using P = pair<ll, ll>;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    vector<int> Query(q);
    vector<P> Q1(q);
    ll cnt = 0;
    map<ll, ll> m1, m2;
    ll s1 = 0, s2 = 0, b = 0;
    ll center = -1;
    {
        vector<ll> nlist;
        REP(i, 0, q) {
            cin >> Query[i];
            if (Query[i] == 1) {
                cin >> Q1[i].first >> Q1[i].second;
                nlist.push_back(Q1[i].first);
                b += Q1[i].second;
            }
        }
        cnt = nlist.size();
        sort(nlist.begin(), nlist.end());
        center = nlist[(cnt - 1) / 2];
        REP(i, 0, nlist.size() / 2) {
            m1[nlist[i]]++;
            s1 += nlist[i];
        }
        REP(i, (nlist.size() + 1) / 2, nlist.size()) {
            m2[nlist[i]]++;
            s2 += nlist[i];
        }
    }
    vector<P> ans(q);
    vector<bool> out(q, false);
    for (int Q = q - 1; Q >= 0; Q--) {
        if (Query[Q] == 1) {
            if (cnt % 2 == 0) {
                ll m1last = m1.rbegin()->first, m2first = m2.begin()->first;
                if (m1last == m2first && m1last == Q1[Q].first) {
                    if (--m2[m2first] == 0) {
                        m2.erase(m2first);
                    }
                    s2 -= m2first;
                    center = m1last;
                    if (--m1[m1last] == 0) {
                        m1.erase(m1last);
                    }
                    s1 -= m1last;
                } else if (m1last == Q1[Q].first) {
                    if (--m1[m1last] == 0) {
                        m1.erase(m1last);
                    }
                    s1 -= m1last;
                    center = m2first;
                    if (--m2[m2first] == 0) {
                        m2.erase(m2first);
                    }
                    s2 -= m2first;
                } else if (m2first == Q1[Q].first) {
                    if (--m2[m2first] == 0) {
                        m2.erase(m2first);
                    }
                    s2 -= m2first;
                    center = m1last;
                    if (--m1[m1last] == 0) {
                        m1.erase(m1last);
                    }
                    s1 -= m1last;
                } else {
                    if (Q1[Q].first < m1last) {
                        if (--m1[Q1[Q].first] == 0) {
                            m1.erase(Q1[Q].first);
                        }
                        s1 -= Q1[Q].first;
                        center = m2first;
                        if (--m2[m2first] == 0) {
                            m2.erase(m2first);
                        }
                        s2 -= m2first;
                    } else {
                        if (--m2[Q1[Q].first] == 0) {
                            m2.erase(Q1[Q].first);
                        }
                        s2 -= Q1[Q].first;
                        center = m1last;
                        if (--m1[m1last] == 0) {
                            m1.erase(m1last);
                        }
                        s1 -= m1last;
                    }
                }
            } else {
                if (cnt == 1) continue;
                if (Q1[Q].first == center) {
                } else if (Q1[Q].first < center) {
                    if (--m1[Q1[Q].first] == 0) {
                        m1.erase(Q1[Q].first);
                    }
                    s1 -= Q1[Q].first;
                    m1[center]++;
                    s1 += center;
                } else {
                    if (--m2[Q1[Q].first] == 0) {
                        m2.erase(Q1[Q].first);
                    }
                    s2 -= Q1[Q].first;
                    m2[center]++;
                    s2 += center;
                }
            }
            cnt--;
            b -= Q1[Q].second;
        } else {
            out[Q] = true;
            if (cnt % 2 == 0) {
                ll tmp = m1.rbegin()->first;
                ans[Q].first = tmp;
                ans[Q].second = b - s1 + s2;
            } else {
                ans[Q].first = center;
                ans[Q].second = b - s1 + s2;
            }
        }
    }

    REP(i, 0, q) {
        if (out[i]) {
            cout << ans[i].first << " " << ans[i].second << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 15972