#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int q, t, a, b;
ll ans;
priority_queue<int> low;
priority_queue<int, vector<int>, greater<int>> high;

int main(){
	scanf("%d%d%d%d", &q, &t, &a, &b);
	ans += b;
	low.push(a);
	for(int i = 0; i < q-1; i++){
		scanf("%d", &t);
		if(t == 1){
			scanf("%d%d", &a, &b);
			ans += (ll)b + abs(low.top() - a);
			if(a < low.top()) low.push(a);
			else high.push(a);
			if(low.size() > high.size() + 1){
				high.push(low.top()); low.pop();
			}else if(low.size() < high.size()){
				ans -= high.top() - low.top();
				low.push(high.top()); high.pop();
			}
		}else printf("%d %lld\n", low.top(), ans);
	}
}