#include<bits/stdc++.h>
using namespace std;
int main(){
	int x;
    cin>>x;
  	priority_queue<long long int> small;
  	priority_queue<long long int,vector<long long int>, greater<long long int> > large;
  	map<long long int,int> cnt;
  	long long int total=0,s=0,l=0;
  	int c=0;
  	for(long long int i=0;i<x;i++){
    	int sub;
        cin>>sub;
        if(sub==1){
            c++;
            long long int a,b;
            cin>>a>>b;
            cnt[a]++;
            total+=b;
            large.push(a);
            l+=a;
            small.push(large.top());
            l-=large.top(),s+=large.top();
            large.pop();
            large.push(small.top());
            l+=small.top(),s-=small.top();
            small.pop();
            if(large.size()>small.size()){
                small.push(large.top());
                l-=large.top(),s+=large.top();
                large.pop();
            }
        }else{
            //cout<<total<<' '<<l<<' '<<s<<endl;
            cout<<small.top()<<' '<<total+l-s+((c)%2)*small.top()<<endl;
        }

    }
}