#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using namespace std;
using ll = long long;

int main()
{
    int q;
    cin >> q;
    priority_queue<ll> l;
    priority_queue<ll, vector<ll>, greater<ll>> r;

    ll ans = 0;
    ll sum_b = 0;
    while(q--){
        int qry;
        cin >> qry;
        if(qry == 1){
            ll a, b;
            cin >> a >> b;
            sum_b += b;
            l.push(a);
            r.push(a);
            if(l.top() > r.top()){
                ll x = l.top();
                ll y = r.top();
                r.pop();
                l.pop();
                r.push(x);
                l.push(y);
                ans += abs(x-y);
            }
        }
        else{
            cout << l.top() << " " << ans + sum_b << endl;
        }
    }
    return 0;
}