#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	int pn = 1;
	if (ci - cn + 16 > cm) {
		if ((ct = getcha()) == '-') { pn = -1; ct = getcha(); }
		A = ct - '0';
		while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';;
		return pn * A;
	}
	else {
		if ((ct = *ci++) == '-') { pn = -1; ct = *ci++; }
		A = ct - '0';
		while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';;
		return pn * A;
	}
}

const int dm = 1 << 22;
char dn[dm], * di = dn;
inline void putint(ll X, ll X2) {
	if (X == 0) {
		*di++ = '0';
	}
	else {
		if (X < 0) {
			*di++ = '-';
			X = -X;
		}
		int keta = 0;
		char C[20];
		while (X) {
			*(C + keta) = '0' + X % 10;
			X /= 10;
			keta++;
		}
		for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	}
	*di++ = ' ';
	if (X2 == 0) {
		*di++ = '0';
	}
	else {
		if (X2 < 0) {
			*di++ = '-';
			X2 = -X2;
		}
		int keta = 0;
		char C[20];
		while (X2) {
			*(C + keta) = '0' + X2 % 10;
			X2 /= 10;
			keta++;
		}
		for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	}
	*di++ = '\n';
}

int tmp[200010], tmp2[200010];
void pakuripair_sort(int N, int A[], int B[]) {
	const int b = 8;
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) {
			tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
			tmp2[kazu[A[i] >> k * b & ((1 << b) - 1)]] = B[i];
		}
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) {
			A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
			B[kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp2[i];
		}
	}
}

int kueri[200010] = {};
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int Q = getint();
	int k = 1;
	int A[200010], B[200010], D[200010] = {};
	rep(i, Q) {
		if (getcha() == '1') {
			getcha();
			A[k] = getint() ^ 1 << 31;
			B[k] = getint();
			D[k] = k;
			k++;
		}
		else {
			getcha();
			kueri[k]++;
		}
	}

	pakuripair_sort(k - 1, A + 1, D + 1);
	int T[200010];
	rep1(i, k - 1) T[D[i]] = i;
	rep1(i, k - 1) D[i] = 0;

	if (k & 1) {
		tmp[k] = k / 2;
		tmp2[k] = k / 2 + 1;
	}
	else {
		tmp[k] = k / 2;
	}

	for (int i = k - 1; i >= 1; i--) {

		int j = T[i];
		int mae = D[j - 1];
		if (!mae) mae = j;
		int ato = D[j + 1];
		if (!ato) ato = j;

		if (i & 1) {
			//たいらからとがってるに
			if (j == tmp[i + 1]) {
				tmp[i] = mae - 1;
				tmp2[i] = ato + 1;
			}
			else if (j < tmp[i + 1]) {
				int ato2 = D[tmp[i + 1] + 1];
				if (!ato2) ato2 = tmp[i + 1];

				tmp[i] = tmp[i + 1];
				tmp2[i] = ato2 + 1;
			}
			else {
				int mae2 = D[tmp[i + 1] - 1];
				if (!mae2) mae2 = tmp[i + 1];

				tmp[i] = mae2 - 1;
				tmp2[i] = tmp[i + 1];
			}
		}
		else {
			if (j <= tmp[i + 1]) tmp[i] = tmp2[i + 1];
			else tmp[i] = tmp[i + 1];
		}

		D[mae] = ato;
		D[ato] = mae;
	}

	rep1(i, k - 1) A[i] = A[i] ^ 1 << 31;

	ll X = 0;
	rep1(i, k - 1) {

		if (i & 1) {
			if (T[i] < tmp[i]) X += A[tmp[i]] - A[T[i]];
			else if (T[i] > tmp2[i]) X += A[T[i]] - A[tmp2[i]];
			X += B[i];
		}
		else {
			X += abs(A[T[i]] - A[tmp[i]]);
			X += B[i];
		}

		rep(j, kueri[i + 1]) putint(A[tmp[i + 1]], X);
	}

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 10496