#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int q;
    cin >> q;
    int b = 0;
    priority_queue<int> hidari;
    reversed_priority_queue<int> migi;
    hidari.push(- INF);
    migi.push(INF);
    int ruih = 0,ruir = 0;
    REP(i,q){
        int order;
        cin >> order;
        if(order == 1){
            int a,tmpb;
            cin >> a >> tmpb;
            b += tmpb;
            if( hidari.size() < migi.size() ){
                if( migi.top() >= a){
                    hidari.push(a);
                    ruih += a;
                }
                else{
                    hidari.push(migi.top());
                    ruih += migi.top();
                    ruir -= migi.top();
                    migi.pop();
                    
                    migi.push(a);
                    ruir += a;
                }
            }
            else if( hidari.size() > migi.size()){
                if( hidari.top() <= a){
                    migi.push(a);
                    ruir += a;
                }
                else{
                    migi.push(hidari.top());
                    ruir += hidari.top();
                    ruih -= hidari.top();
                    hidari.pop();

                    hidari.push(a);
                    ruih += a;
                }
            }
            else{
                if(hidari.top() >= a){
                    hidari.push(a);
                    ruih += a;
                }
                else{
                    migi.push(a);
                    ruir += a;
                }
            }


        }
        else{
            /*
            debug(hidari.size());
            debug(migi.size());
            debug(hidari.top());
            debug(migi.top());
            debug(b);
            debug(ruih);
            debug(ruir);
            */
            if(hidari.size() < migi.size()){
                cout << migi.top() << " " << b + migi.top() * ( int(hidari.size()) - 1)- ruih + ruir - (migi.top() * ( int(migi.size()) - 1 )) << endl;
            }
            else{
                cout << hidari.top() << " " << b + hidari.top() * ( int(hidari.size()) - 1) - ruih + ruir - (hidari.top() * ( int(migi.size()) - 1) ) << endl;
            }
        }
    }

}

Measured memory_bytes: 3828