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

long long A,B,mid,sum1,sum2;
long long q;
priority_queue<long long,vector<long long> > q1;
priority_queue<long long,vector<long long>,greater<long long> > q2;

int main(){
	cin>>q;
	long long n;
	for(int i=0;i<q;i++){
		cin>>n;
		if(i==0){
		    long long a,b;
			cin>>a>>b;
			B+=b;
			mid=a;
			continue;
		}
		if(n==1){
			long long a,b;
			cin>>a>>b;
			B+=b;
			if(a>mid){
				q2.push(a);
				sum2+=a;
			}else{
				q1.push(a);
				sum1+=a;
			}
			while(q2.size()>q1.size()+1){
				long long m=q2.top();
				q2.pop();
				sum2-=m;
				q1.push(mid);
				sum1+=mid;
				mid=m;
			}
			while(q1.size()>q2.size()){
				long long m=q1.top();
				q1.pop();
				sum1-=m;
				q2.push(mid);
				sum2+=mid;
				mid=m;
			}
		}else if(n==2){
			long long sz1=q1.size(),sz2=q2.size();
			cout<<mid<<" "<<sz1*mid-sum1+sum2-sz2*mid+B<<endl;
		}
    }
	return 0;
}	