#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

#define KI_MAX (1 << 18) /* 262144 */

int count_ki[KI_MAX * 2 - 1];
int64_t sum_ki[KI_MAX * 2 - 1];

void add_count(int idx, int delta) {
	int pos = (KI_MAX - 1) + idx;
	count_ki[pos] += delta;
	while (pos > 0) {
		pos = (pos - 1) / 2;
		count_ki[pos] += delta;
	}
}

int get_count_i(int idx, int qmin, int qmax, int smin, int smax) {
	if (qmax <= smin || smax <= qmin) { /* クエリがセグメントから完全に外れている */
		return 0;
	} else if (qmin <= smin && smax <= qmax) { /* セグメントがクエリに完全に含まれる */
		return count_ki[idx];
	} else {
		int smid = smin + (smax - smin) / 2;
		int left = get_count_i(idx * 2 + 1, qmin, qmax, smin, smid);
		int right = get_count_i(idx * 2 + 2, qmin, qmax, smid, smax);
		return left + right;
	}
}

int get_count(int min, int max) {
	return min >= max ? 0 : get_count_i(0, min, max, 0, KI_MAX);
}

void add_sum(int idx, int64_t delta) {
	int pos = (KI_MAX - 1) + idx;
	sum_ki[pos] += delta;
	while (pos > 0) {
		pos = (pos - 1) / 2;
		sum_ki[pos] += delta;
	}
}

int64_t get_sum_i(int idx, int qmin, int qmax, int smin, int smax) {
	if (qmax <= smin || smax <= qmin) { /* クエリがセグメントから完全に外れている */
		return 0;
	} else if (qmin <= smin && smax <= qmax) { /* セグメントがクエリに完全に含まれる */
		return sum_ki[idx];
	} else {
		int smid = smin + (smax - smin) / 2;
		int64_t left = get_sum_i(idx * 2 + 1, qmin, qmax, smin, smid);
		int64_t right = get_sum_i(idx * 2 + 2, qmin, qmax, smid, smax);
		return left + right;
	}
}

int64_t get_sum(int min, int max) {
	return min >= max ? 0 : get_sum_i(0, min, max, 0, KI_MAX);
}

int hikaku(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a < b ? -1 : a > b;
}

int Q;
int query[271828], a[271828], b[271828];

int za_count, za_count_beta;
int za[777777];

int za_get(int taisyou) {
	int l = 0, r = za_count - 1;
	while (l <= r) {
		int m = l + (r - l) / 2;
		if (za[m] == taisyou) return m;
		else if (za[m] < taisyou) l = m + 1;
		else r = m - 1;
	}
	printf("ERROR: %d not found!!!!!\n", taisyou);
	exit(2);
}

int main(void) {
	int i;
	int64_t b_sum = 0;
	if (scanf("%d", &Q) != 1) return 1;
	za_count_beta = 0;
	for (i = 0; i < Q; i++) {
		if (scanf("%d", &query[i]) != 1) return 1;
		if (query[i] == 1) {
			if (scanf("%d%d", &a[i], &b[i]) != 2) return 1;
			za[za_count_beta++] = a[i];
		} else if (query[i] == 2) {
			/* nop */
		} else {
			puts("INVALID QUERY");
			return 2;
		}
	}
	qsort(za, za_count_beta, sizeof(*za), hikaku);
	za_count = 1;
	for (i = 1; i < za_count_beta; i++) {
		if (za[za_count - 1] != za[i]) {
			za[za_count++] = za[i];
		}
	}

	for (i = 0; i < Q; i++) {
		if (query[i] == 1) {
			int idx = za_get(a[i]);
			add_count(idx, 1);
			add_sum(idx, a[i]);
			b_sum += b[i];
		} else {
			int all = get_count(0, za_count);
			int target = (all + 1) / 2;
			int count_left, count_right;
			int64_t sum_left, sum_right;
			int less = -1, ge = za_count - 1;
			while (less + 1 < ge) {
				int mid = less + (ge - less) / 2;
				if (get_count(0, mid + 1) < target) less = mid; else ge = mid;
			}
			count_left = get_count(0, ge);
			count_right = get_count(ge + 1, za_count);
			sum_left = get_sum(0, ge);
			sum_right = get_sum(ge + 1, za_count);
			printf("%d %" PRId64 "\n", za[ge],
				(int64_t)za[ge] * count_left - sum_left +
				sum_right - (int64_t)za[ge] * count_right +
				b_sum);
		}
	}

	return 0;
}

/*

左右に半分ずつに分かれる位置で最小になる
bは単純に足していく

*/


Measured memory_bytes: 13396