#include <bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// using namespace atcoder;

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
template<typename T>
ll sz(priority_queue<T, vector<T>> &pq) {return (ll)pq.size(); }
template<typename T>
ll sz(priority_queue<T, vector<T>, greater<T>> &pq) {return (ll)pq.size(); }
ll sz(string &s) {return (ll)s.size(); } 
ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b; }
bool checkindex(ll i,ll n){ return (i < n && i >= 0); }

int main(){
    ll n;
    cin >> n;
    ll bsum = 0,rasum = 0,lasum = 0,temp = 0;
    priority_queue<ll,llVEC,greater<ll>> pq_r;
    priority_queue<ll,llVEC> pq_l;

    ll q,a,b;
    rep(i,0,n){
        cin >> q;
        if(q == 2){
            ll minx;
            if(pq_r.empty()){
                cout << pq_l.top() << " " << bsum << endl;
            }
            else if(pq_l.empty()){
                cout << pq_r.top() << " " << bsum << endl;
            }
            else if(sz(pq_r) == sz(pq_l)){
                minx = pq_l.top();
            }
            else if(sz(pq_l) > sz(pq_r)){
                minx = pq_l.top();
            }
            else{
                minx = pq_r.top();
            }

            //cout << bsum  << " " << lasum << " " << rasum << " " << ((ll)(sz(pq_r)) - (ll)(sz(pq_l))) << endl;
            if(!pq_r.empty() && !pq_l.empty()) cout << minx << " " << bsum - lasum + rasum + minx*(sz(pq_l) - sz(pq_r)) << endl;
        }
        else{
            cin >> a >> b;
            bsum += b;
            if(pq_l.empty() && pq_r.empty()){
                pq_r.push(a);
                rasum += a;
            }
            else if(sz(pq_r) == sz(pq_l)){
                if(pq_r.top() <= a){
                    pq_r.push(a);
                    rasum += a;
                }
                else{
                    pq_l.push(a);
                    lasum += a;
                }
            }
            else if(sz(pq_l) > sz(pq_r)){
                if(pq_l.top() > a){
                    rasum += pq_l.top();
                    lasum -= pq_l.top();
                    pq_r.push(pq_l.top());
                    pq_l.pop();
                    pq_l.push(a);
                    lasum += a;
                }
                else{
                    pq_r.push(a);
                    rasum += a;
                }
            }
            else{
                if(pq_r.top() < a){
                    lasum += pq_r.top();
                    rasum -= pq_r.top();
                    pq_l.push(pq_r.top());
                    pq_r.pop();
                    pq_r.push(a); 
                    rasum += a;
                }
                else{
                    pq_l.push(a);
                    lasum += a;
                }
            }
        }
    }
}


Measured memory_bytes: 4820