#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}


priority_queue<ll> asmall;
priority_queue<ll, vector<ll>, greater<ll> > alarge;


int main(){
    int q;
    cin >> q;
    ll bsum = 0;
    ll amid = 0;
    ll n = 0;
    ll asmallsum = 0, alargesum = 0;

    for(int i = 0; i < q; i++){
        int x;
        cin >> x;
        if(x == 1){
            int a, b;
            cin >> a >> b;
            bsum += b;
            if(n == 0){
                amid = a;
            }
            else if(n % 2 == 0){
                if(asmall.top() > a){
                    amid = asmall.top();
                    asmallsum -= asmall.top();
                    asmallsum += a;
                    asmall.pop();
                    asmall.push(a);
                }
                else if(alarge.top() < a){
                    amid = alarge.top();
                    alargesum -= alarge.top();
                    alargesum += a;
                    alarge.pop();
                    alarge.push(a);
                }
                else{
                    amid = a;
                }
            }
            else{
                if(a > amid){
                    asmallsum += amid;
                    asmall.push(amid);
                    alargesum += a;
                    alarge.push(a);
                }
                else{
                    asmallsum += a;
                    asmall.push(a);
                    alargesum += amid;
                    alarge.push(amid);
                }
            }
            n++;
        }
        else{
            if(n == 0){
                cout << 0 << " " << 0 << endl;
            }
            else if(n % 2 == 0){
                ll y = asmall.top();
                ll ret = alargesum - asmallsum + bsum;
                cout << y << " " << ret << endl;
            }
            else{
                ll y = amid;
                ll ret = alargesum - asmallsum + bsum;
                cout << y << " " << ret << endl;
            }
        }
    }




    return 0;
}


Measured memory_bytes: 3828