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

typedef long long ll;
const int LOG = 30, ADD = 1e9 + 10, N = ADD << 1;

struct fenwick {
	unordered_map<ll, ll> cnt, sum;
	void add(ll x) {
		ll val = x;
		for (x += ADD; x < N; x += x & -x)
			cnt[x]++, sum[x] += val;
	}
	int get(ll dex) { // 1 2 3 ...
		ll now = 0;
		for (int i = LOG; ~i; i--)
			if(now + (1 << i) < N && cnt[now + (1 << i)] < dex)
				dex -= cnt[now += 1 << i];
		return now + 1 - ADD;
	}
	ll GET(ll dex) { // 1 2 3 ...
		ll res = 0, now = 0;
		for (int i = LOG; ~i; i--)
			if(now + (1 << i) < N && cnt[now + (1 << i)] < dex) {
				dex -= cnt[now += 1 << i];
				res += sum[now];
			}
		return res + (now + 1 - ADD) * dex;
	}
} CNT;

ll q, type, a, b, cnt, s, to_add;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> q;
	while(q--) {
		cin >> type;
		if(type == 1) {
			cin >> a >> b;
			CNT.add(a);
			s += a;
			to_add += b;
			cnt++;
		}
		else {
			ll dex = (cnt - 1) / 2 + 1;
			ll x = CNT.get(dex);
			cout << x << ' ' << to_add + (2 * (dex - 1) - cnt) * x + s - 2 * CNT.GET(dex - 1) << '\n';
		}
	}
	return 0;
}