#include <bits/stdc++.h>
using namespace std;
// #define LOCAL // 提出時はコメントアウト
#define DEBUG_

typedef long long ll;
const double EPS = 1e-9;
const ll INF = ((1LL<<62)-(1LL<<31));
typedef vector<ll> vecl;
typedef pair<ll, ll> pairl;
template<typename T, typename U> using mapv = map<T,vector<U>>;

#define ALL(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define contains(S,x) find(ALL(S),x) != S.end()
ll llceil(ll a,ll b) { return (a+b-1)/b; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> vector<vector<T>> genarr(ll n, ll m, T init) { return vector<vector<T>>(n,vector<T>(m,init)); }

///// DEBUG
#define DUMPOUT cerr
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
template<typename T>istream&operator>>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<typename T,typename U>ostream&operator<<(ostream&os,pair<T,U>&pair_var){os<<"("<<pair_var.first<<", "<<pair_var.second<<")";return os;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&vec){os<<"{";for(int i=0;i<vec.size();i++){os<<vec[i]<<(i+1==vec.size()?"":", ");}
os<<"}";return os;}
template<typename T,typename U>ostream&operator<<(ostream&os,map<T,U>&map_var){os<<"{";repi(itr,map_var){os<<*itr;itr++;if(itr!=map_var.end())os<<", ";itr--;}
os<<"}";return os;}
template<typename T>ostream&operator<<(ostream&os,set<T>&set_var){os<<"{";repi(itr,set_var){os<<*itr;itr++;if(itr!=set_var.end())os<<", ";itr--;}
os<<"}";return os;}
void dump_func(){DUMPOUT<<endl;}
template<class Head,class...Tail>void dump_func(Head&&head,Tail&&...tail){DUMPOUT<<head;if(sizeof...(Tail)>0){DUMPOUT<<", ";}
dump_func(std::move(tail)...);}
#ifndef LOCAL
#undef DEBUG_
#endif
#ifdef DEBUG_
#define DEB
#define dump(...)                                                          \
DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
        << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
        << endl                                                            \
        << "    ",                                                         \
    dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif

//////////

// SegTree: https://atcoder.github.io/ac-library/document_ja/segtree.html

// @param n `0 <= n`
// @return minimum non-negative `x` s.t. `n <= 2**x`
int ceil_pow2(int n) {
    int x = 0;
    while ((1U << x) < (unsigned int)(n)) x++;
    return x;
}

// @param n `1 <= n`
// @return minimum non-negative `x` s.t. `(n & (1 << x)) != 0`
int bsf(unsigned int n) {
#ifdef _MSC_VER
    unsigned long index;
    _BitScanForward(&index, n);
    return index;
#else
    return __builtin_ctz(n);
#endif
}


template <class S, S (*op)(S, S), S (*e)()> struct segtree {
  public:
    segtree() : segtree(0) {}
    segtree(int n) : segtree(std::vector<S>(n, e())) {}
    segtree(const std::vector<S>& v) : _n(int(v.size())) {
        log = ceil_pow2(_n);
        size = 1 << log;
        d = std::vector<S>(2 * size, e());
        for (int i = 0; i < _n; i++) d[size + i] = v[i];
        for (int i = size - 1; i >= 1; i--) {
            update(i);
        }
    }

    void set(int p, S x) { // O(logn)
        assert(0 <= p && p < _n);
        p += size;
        d[p] = x;
        for (int i = 1; i <= log; i++) update(p >> i);
    }

    S get(int p) { // O(1)
        assert(0 <= p && p < _n);
        return d[p + size];
    }

    S prod(int l, int r) { // [l,r): O(logn)
        assert(0 <= l && l <= r && r <= _n);
        S sml = e(), smr = e();
        l += size;
        r += size;

        while (l < r) {
            if (l & 1) sml = op(sml, d[l++]);
            if (r & 1) smr = op(d[--r], smr);
            l >>= 1;
            r >>= 1;
        }
        return op(sml, smr);
    }

    S all_prod() { return d[1]; } // [0,n)

    template <bool (*f)(S)> int max_right(int l) { // segtree上で二分探索 O(logn)
        return max_right(l, [](S x) { return f(x); });
    }
    template <class F> int max_right(int l, F f) { // segtree上で二分探索 O(logn)
        assert(0 <= l && l <= _n);
        assert(f(e()));
        if (l == _n) return _n;
        l += size;
        S sm = e();
        do {
            while (l % 2 == 0) l >>= 1;
            if (!f(op(sm, d[l]))) {
                while (l < size) {
                    l = (2 * l);
                    if (f(op(sm, d[l]))) {
                        sm = op(sm, d[l]);
                        l++;
                    }
                }
                return l - size;
            }
            sm = op(sm, d[l]);
            l++;
        } while ((l & -l) != l);
        return _n;
    }

    template <bool (*f)(S)> int min_left(int r) { // segtree上で二分探索 O(logn)
        return min_left(r, [](S x) { return f(x); });
    }
    template <class F> int min_left(int r, F f) { // segtree上で二分探索 O(logn)
        assert(0 <= r && r <= _n);
        assert(f(e()));
        if (r == 0) return 0;
        r += size;
        S sm = e();
        do {
            r--;
            while (r > 1 && (r % 2)) r >>= 1;
            if (!f(op(d[r], sm))) {
                while (r < size) {
                    r = (2 * r + 1);
                    if (f(op(d[r], sm))) {
                        sm = op(d[r], sm);
                        r--;
                    }
                }
                return r + 1 - size;
            }
            sm = op(d[r], sm);
        } while ((r & -r) != r);
        return 0;
    }

  private:
    int _n, size, log;
    std::vector<S> d;

    void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); }
};

// (S,*): 結合律の成立と単位元の存在を満たせばOK
// 交換律は必要ないので演算の向きを恣意的に決めてOK

struct S {
    ll count;
    ll sum;
};

S op(S l, S r) { return {l.count + r.count, l.sum + r.sum}; } // S * S

S e() { return {0,0}; } // モノイドの単位元


//// 座標圧縮

template<class T, class U>
struct Zarted {
    unordered_map<T,ll> corresp_table; // corresp_table[x] → z
    unordered_map<T,ll> inv_corresp_table; // inv_corresp_table[z] → x
    vector<U> Z; 
};

template<class T, class U>
U id_convert(T t) { return t; } 

// 座標圧縮 & T → U 
// Xの位置情報は固定したままXを変換してZに格納する: Z[i] = convert(X[j])
// Xはコピーされる
template<class T, class U>
Zarted<T,U> zarts(vector<T> X, bool already_sorted, bool already_unique, const auto sort_algorism, function<U(T)> convert=id_convert<T,U>) { 
    unordered_map<T,ll> corresp_table;
    unordered_map<T,ll> inv_corresp_table;

    vector<U> Z(X.size());
    
    if (!already_sorted) {
        sort(ALL(X),sort_algorism);
    }
    if (!already_unique) {
        X.erase(unique(ALL(X)), X.end());
    }

    rep(i,X.size()) {
        T x = X[i];
        ll z = lower_bound(ALL(X), x, sort_algorism) - X.begin();
        corresp_table[x] = z; // x → z
        inv_corresp_table[z] = x; // z → x
        Z[z] = convert(x); // Z[z] = ?
    }
    
    return Zarted<T,U>{corresp_table,inv_corresp_table,Z};
}




struct Query {
    ll t;
    ll a;
    ll b;
};


int main() {
    #ifdef LOCAL
    ifstream in("../../Atcoder/input.txt");
    cin.rdbuf(in.rdbuf());
    #endif

    ll Q;
    cin>>Q;

    vecl A;
    ll sum_b = 0;

    const ll MAX = 2e5+10;
    segtree<S, op, e> seg(MAX);
    ll count = 0;
    
    vector<Query> X;
    vecl P;
    rep(q,Q) {
        ll t;
        cin>>t;
        if (t == 1) {
            ll a,b;
            cin>>a>>b;
            X.push_back({t,a,b});
            P.push_back(a);
        }
        else {
            X.push_back({t,0,0});
        }
    }

    auto Z = zarts<ll,ll>(P,false,false,less<ll>());

    
    rep(q,Q) {
        auto [t,a,b] = X[q];
        if (t == 1) {
            sum_b += b;
            // A.push_back(a);
            S x = seg.get(Z.corresp_table[a]);
            seg.set(Z.corresp_table[a],{x.count+1, x.sum + a});
            count++;
        } 
        else {
            // sort(ALL(A));
            ll l = -1;
            ll r = MAX; 

            ll boundary = count % 2 == 0 ? count/2 - 1 : count/2;

            // (l,r]
            while (r-l > 1) {
                ll mid = (l+r)/2;
                // dump(mid,seg.prod(0,mid).count);
                if (seg.prod(0,mid).count > boundary){
                    r = mid;
                }
                else {
                    l = mid;
                }
            }

            ll median_i = l;
            ll median = Z.inv_corresp_table[l];
            
            ll ans = 0;
            ans += seg.prod(median_i+1,MAX).sum;
            ans -= seg.prod(0,median_i).sum;
            ans += (seg.prod(median_i+1,MAX).count - seg.prod(0,median_i).count) * (-1) * median;

            dump(median_i,median,ans);
            dump(median,ans);
            ans += sum_b;
        
            cout << median << " " << ans << endl;
        }
    }



    return 0;
}


Measured memory_bytes: 35860