//author Eterna
#define Hello The_Cruel_World!
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<cmath>
#include<climits>
#include<deque>
#include<functional>
#include<complex>
#include<numeric>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define Pi acos(-1.0)
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))
#define pb(x) push_back(x)
#define lowbit(x) (x & -x)
#define FRIN freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\in.txt", "r", stdin)
#define FROUT freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\out.txt", "w", stdout)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ls(x) arr[x].child[0]
#define rs(x) arr[x].child[1]
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int maxn = 2e5;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
const double eps = 1e-7;
inline int read_int() {
	char c;
	int ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
inline ll read_ll() {
	char c;
	ll ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
struct node {
	int value, key, Size, child[2];
	ll sum;
}arr[maxn + 5];
int tot;
inline void Push_Up(int index) {
	arr[index].Size = arr[arr[index].child[0]].Size + arr[arr[index].child[1]].Size + 1;
	arr[index].sum = arr[ls(index)].sum + arr[rs(index)].sum + arr[index].value;
}
void Split(int root, int& a, int& b, int value) {
	if (!root) {
		a = b = 0;
		return;
	}
	if (arr[root].value <= value)a = root, Split(arr[root].child[1], arr[a].child[1], b, value);
	else b = root, Split(arr[root].child[0], a, arr[b].child[0], value);
	Push_Up(root);
}
void Merge(int& root, int a, int b) {
	if (!a || !b) {
		root = a + b;
		return;
	}
	if (arr[a].key < arr[b].key)root = a, Merge(arr[root].child[1], arr[a].child[1], b);
	else root = b, Merge(arr[root].child[0], a, arr[b].child[0]);
	Push_Up(root);
}
inline void Insert(int& root, int value) {
	int x = 0, y = 0, z = ++tot;
	arr[z].value = arr[z].sum = value, arr[z].key = rand(), arr[z].Size = 1;
	Split(root, x, y, value);
	Merge(x, x, z);
	Merge(root, x, y);
}
int Kth_number(int root, int k) {
	while (arr[arr[root].child[0]].Size + 1 != k) {
		if (arr[arr[root].child[0]].Size >= k)root = arr[root].child[0];
		else k -= (arr[arr[root].child[0]].Size + 1), root = arr[root].child[1];
	}
	return arr[root].value;
}
ll a, b, sumb;
int sum, root;
int main()
{
	srand(19260817);
	for (int q = read_int(), op; q; --q) {
		op = read_int();
		if (op == 1) {
			a = read_ll(), b = read_ll();
			sumb += b;
			++sum;
			Insert(root, a);
		}
		else {
			int mid = 0, sz1 = 0, sz2 = 0;
			if (sum & 1)mid = (sum + 1) / 2;
			else mid = sum / 2;
			sz1 = mid, sz2 = sum - mid;
			int v = Kth_number(root, mid);
			int r1 = 0, r2 = 0;
			Split(root, r1, r2, v);
			ll Left_sum = arr[r1].sum, Right_sum = arr[r2].sum;
			if (arr[r1].Size > sz1) {
				int u = arr[r1].Size - sz1;
				sz1 += u;
				sz2 -= u;
			}
			Merge(root, r1, r2);
			ll ans = sumb + 1ll * v * sz1 - Left_sum + Right_sum - 1ll * v * sz2;
			//cout << Left_sum << " " << Right_sum << " " << sz1 << " " << sz2 << endl;
			cout << v << " " << ans << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 6912