#include <queue>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#define ll long long
int main(){
	ll q, k, a, b, acc = 0, l = 0, r = 0, n = 0;
	scanf("%lld", &q);
	vector<ll> v;
	priority_queue<ll> pq1;
	priority_queue<ll, vector<ll>, greater<ll> > pq2;
	for (ll i = 0; i < q; i++){
		scanf("%lld", &k);
		if (k == 1){
			n++;
			scanf("%lld %lld", &a, &b);
			acc += b;
			if (pq2.empty() || a >= pq2.top()){
				pq2.push(a);
				r += a;
			}else{
				pq1.push(a);
				l += a;
			}
			while (pq1.size() < n / 2){
				l += pq2.top();
				r -= pq2.top();
				pq1.push(pq2.top());
				pq2.pop();
			}
			while (pq1.size() > n / 2){
				r += pq1.top();
				l -= pq1.top();
				pq2.push(pq1.top());
				pq1.pop();
			}
		}else if (k == 2){
			if (n % 2 == 0){
				printf("%lld %lld\n", pq1.top(), r - l + acc);
			}else{
				printf("%lld %lld\n", pq2.top(), r - l - pq2.top() + acc);
			}
		}
	}
}