// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

template <typename T>
class Bit {
private:
    V<T> data;
    T identity_ele;

public:
    Bit(ll size, T identity_ele) : identity_ele(identity_ele) {
        ll newsize = 1;
        while(newsize < size) {
            newsize = newsize << 1;
        }
        data = V<T>(newsize + 1, identity_ele);
    }

    /*
     * 0-origin
     * sum of [0, pos)
     */
    T sum(ll pos) {
        T ret = identity_ele;
        while(pos > 0) {
            ret += data[pos];
            pos -= pos & -pos;
        }
        return ret;
    }

    /*
     * 0-origin
     * sum of [l, r)
     */
    T sum(ll l, ll r) {
        return sum(r) - sum(l);
    }

    /*
     * 0-origin
     */
    void add(ll pos, T delta) {
        pos++;
        while(pos <= data.size()) {
            data[pos] = data[pos] + delta;
            pos += pos & -pos;
        }
    }
};

using TLL = tuple<ll, ll, ll>;

int main() {
    ll Q;
    cin >> Q;
    V<TLL> query;
    V<ll> nlis;
    for(ll i = 0; i < Q; i++) {
        ll q;
        cin >> q;
        if(q == 1) {
            ll a, b;
            cin >> a >> b;
            query.emplace_back(q, a, b);
            nlis.push_back(a);
        } else {
            query.emplace_back(q, 0, 0);
        }
    }
    
    {
        sort(ALL(nlis));
        auto ite = unique(ALL(nlis));
        nlis.erase(ite, nlis.end());
    }

    auto get_idx = [&](ll n) {
        return distance(nlis.begin(),
                        lower_bound(ALL(nlis), n));
    };

    Bit<ll> bt(nlis.size() + 10, 0);
    Bit<ll> pbt(nlis.size() + 10, 0);
    Bit<ll> mbt(nlis.size() + 10, 0);
    ll cnt = 0;
    ll bsum = 0;
    
    for(const auto ele : query) {
        ll q, a, b;
        tie(q, a, b) = ele;
        if(q == 1) {
            ll ida = get_idx(a);
            bt.add(ida, 1);
            pbt.add(ida, a);
            mbt.add(ida, -a);
            bsum += b;
            cnt++;
            continue;
        }
        auto calc_f = [&](ll xidx) {
            ll cnt_p = bt.sum(0, xidx);
            ll cnt_m = cnt - cnt_p - bt.sum(xidx, xidx + 1);
            ll x = nlis[xidx];
            ll ret = mbt.sum(0, xidx) + pbt.sum(xidx + 1, nlis.size()) + cnt_p * x - cnt_m * x + bsum;
            DEBUG(x, mbt.sum(0, xidx), pbt.sum(xidx + 1, nlis.size()), cnt_p * x - cnt_m * x, ret);
            return ret;
        };
        
        ll xidx0 = 0, xidx3 = nlis.size() - 1;
        while(abs(xidx0 - xidx3) > 3) {
            ll dic = xidx3 - xidx0;
            ll xidx1 = xidx0 + dic / 3;
            ll xidx2 = xidx0 + dic * 2 / 3;
            ll f1 = calc_f(xidx1);
            ll f2 = calc_f(xidx2);
            DEBUG(xidx1, xidx2, f1, f2);
            if(f1 <= f2) xidx3 = xidx2;
            else xidx0 = xidx1;
        }
        ll fans = 5e15;
        ll xans_idx = 0;
        for(ll xidx = xidx0; xidx <= xidx3; xidx++) {
            if(!(0 <= xidx && xidx < nlis.size())) continue;
            ll fval = calc_f(xidx);
            if(fans > fval) {
                fans = fval;
                xans_idx = xidx;
            }
        }
        cout << nlis[xans_idx] << ' ' << calc_f(xans_idx) << endl;
    }
    return 0;
}



Measured memory_bytes: 12204