#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int q;
struct A {
	int a, b, t, k;
};
vector<A>a;
vector<int>b;
int dat[300000];
int dat2[300000];
void update(int x) {
	while (x <= b.size()) {
		dat[x]++;
		x += x & -x;
	}
}
int sum(int x) {
	int sum = 0;
	while (x > 0) {
		sum += dat[x];
		x -= x & -x;
	}
	return sum;
}
void update2(int x, int y) {
	while (x <= b.size()) {
		dat2[x] += y;
		x += x & -x;
	}
}
int sum2(int x) {
	int sum = 0;
	while (x > 0) {
		sum += dat2[x];
		x -= x & -x;
	}
	return sum;
}
signed main() {
	cin >> q;
	for (int i = 0; i < q; i++) {
		int u, v, r;
		cin >> r;
		if (r == 1) {
			cin >> u >> v;
			a.push_back(A{ u,v,i,1 });
			b.push_back(u);
		}
		else a.push_back(A{ 0,0,i,2 });
	}
	sort(all(b));
	b.erase(unique(all(b)), b.end());
	int res = 0, rer = 0, wa = 0;
	for (int i = 0; i < q; i++) {
		if (a[i].k == 1) {
			update(lower_bound(all(b), a[i].a) - b.begin() + 1);
			res += a[i].b;
			rer++;
			wa += a[i].a;
			update2(lower_bound(all(b), a[i].a) - b.begin() + 1, a[i].a);
		}
		else {
			int ok = b.size(), ng = 0;
			if (rer % 2 == 0) {
				while (abs(ok - ng) > 1) {
					int k = (ok + ng) / 2;
					if (sum(k) >= rer / 2) {
						ok = k;
					}
					else ng = k;
				}
			}
			else {
				while (abs(ok - ng) > 1) {
					int k = (ok + ng) / 2;
					if (sum(k) >= rer / 2 + 1) {
						ok = k;
					}
					else ng = k;
				}
			}
			int t = sum(ok - 1);
			int r = sum(ok);
			cout << b[ok - 1] << " " << t * b[ok - 1] - sum2(ok - 1) - (rer - r) * b[ok - 1] + (wa - sum2(ok)) + res << endl;
		}
	}
}

Measured memory_bytes: 15208