#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) os << "[" << el.first << " " << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) os << el << " "; return os; }

ll Q;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> Q;
}

int solve(){
    ll sumB=0;
    int n=0;
    // ll mid=0;
    ll f=0;
    multiset<pair<ll,int>> se;
    multiset<pair<ll,int>>::iterator mid;
    vector<pair<int,ll>> ans;
    for (int i = 0; i < Q; i++)
    {
        int q;
        cin >> q;
        if(q==1){
            n++;
            ll a,b;
            cin >> a >> b;
            se.insert({a,n});
            sumB+=b;
            if(n==1){mid = se.begin();}
            else if(n%2==0 && a<(*mid).first){
                // a1 a2 a3 からanの追加
                // a a1 a2 a3 mid=a2→a1の場合とか
                f+=abs((*mid).first-a);
                --mid;
                // auto itr = se.find(mid);
                // ll mid_tmp = max(a,*(--itr));
                // f+=abs(mid-mid_tmp);
                // mid = mid_tmp;
            }
            else if(n%2==1 && a>=(*mid).first){
                f+=abs((*mid).first-a);
                // auto itr = se.find(mid);
                // ll mid_tmp = max(a,*(++itr));
                auto mid_tmp = mid;
                mid_tmp++;
                f+=((*mid).first-(*mid_tmp).first);
                mid = mid_tmp;
            }
            else{f+=abs((*mid).first-a);}
        }
        else{
            ans.emplace_back((*mid).first,f+sumB);
        }
    }

    for(auto a:ans) cout << a.first << " " << a.second << "\n";
    return 0;
}

// priority_queueをふたつ用意して
// 区間の左側と右側を管理すれば良い。
int writer_solve(){

    ll sumB=0;
    int n=0;
    ll f=0;
    ll sum_for=0,sum_back=0;
    priority_queue<ll> foward; // 最大値を返す。
    priority_queue<ll,vector<ll>,greater<ll>> back; // 最小値を返す。
    vector<pair<int,ll>> ans;
    for (int i = 0; i < Q; i++)
    {
        int q;
        cin >> q;
        if(q==1){
            n++;
            ll a,b;
            cin >> a >> b;
            sumB+=b;
            if(foward.size()>back.size()){
                // 後方に入れる。
                ll t=foward.top();
                if(a>=t){
                    back.push(a);
                    sum_back+=a;
                }
                else{
                    back.push(t);
                    sum_back+=t;
                    sum_for-=t;
                    sum_for+=a;
                    foward.pop();
                    foward.push(a);
                }
            }
            else{
                // 前方に入れる。
                if(foward.empty()) {foward.push(a);sum_for+=a;continue;}
                ll t=back.top();
                if(a<=t){
                    foward.push(a);
                    sum_for+=a;
                }
                else{
                    foward.push(t);
                    sum_for+=t;
                    sum_back-=back.top();
                    sum_back+=a;
                    back.pop();
                    back.push(a);
                }
            }

        }
        else{
            ll mid=foward.top();
            ll a=mid*(int)foward.size()-sum_for+sum_back-mid*(int)back.size();
            ans.emplace_back(mid,a+sumB);
        }
    }

    for(auto a:ans) cout << a.first << " " << a.second << "\n";
    return 0;
}

int main()
{
    input();
    // solve();
    writer_solve();
    return 0;
}


Measured memory_bytes: 5868