#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < pii, int > a, pair < pii, int > b)//true for a before b
{
	if(a.F.F/300 < b.F.F/300)
		return 1;
	if(a.F.F/300 > b.F.F/300)
		return 0;
	if(a.F.S < b.F.S)
		return 1;
	if(a.F.S > b.F.S)
		return 0;
	if(a.F <= b.F)
		return 1;
	return 0;
}

const int N = (2e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 2*550;
const int SQRT = BUCK+9;

#include <bits/extc++.h>
using namespace __gnu_pbds;
typedef pair < int, int > __T;//type of set
typedef tree < __T, null_type, less < __T > , rb_tree_tag, tree_order_statistics_node_update > ordered_set;
ordered_set SET;

vi queries[N];
pair < pii, int > a[N];
map < int, int > mapp;
ll st[M], arr[N];

void update(int node, int l, int r, int ind, ll val)
{
	if(l > r || ind < l || ind > r)
		return;
	if(l == r)
	{
		st[node] = val;
		return;
	}
	int mid = (l+r)>>1;
	int left = node<<1;
	int right = left|1;
	update(left,l,mid,ind,val);
	update(right,mid+1,r,ind,val);
	st[node] = st[left] + st[right];
	return;
}

ll query(int node, int l, int r, int p, int q)
{
	if(l > r || p > q || l > q || p > r)
		return 0LL;
	if(l >= p && r <= q)
		return st[node];
	int mid = (l+r)>>1;
	int left = node<<1;
	int right = left|1;
	return (query(left,l,mid,p,q) + query(right,mid+1,r,p,q));
}

void solve()
{
	int q, i, t, x, y, cnt_upd_queries = 0, ind, SIZE;
	ll sum = 0, ans, left, right, cnt_left, cnt_right;
	cin >> q;
	fo(i,1,q+1)
	{
		cin >> t;
		if(t == 1)
		{
			cin >> x >> y;
			queries[i] = {t,x,y,++cnt_upd_queries};
			a[cnt_upd_queries] = {{x,cnt_upd_queries},cnt_upd_queries};
		}
		else
			queries[i] = {t};
	}
	sort(a+1,a+cnt_upd_queries+1);
	fo(i,1,cnt_upd_queries+1)
		mapp[a[i].S] = i;
	sum = 0;
	fo(i,1,q+1)
	{
		if(sz(queries[i]) == 1)
		{
			SIZE = sz(SET);
			if(SET.empty())
				ans = 0;
			else if(SIZE&1)
			{
				ind = SET.find_by_order(SIZE/2)->S;
				cnt_left = cnt_right = SIZE/2;
				left = query(1,1,cnt_upd_queries,1,mapp[ind]-1);
				right = query(1,1,cnt_upd_queries,mapp[ind]+1,cnt_upd_queries);
				ans = (cnt_left*arr[ind] - left) + (right - cnt_right*arr[ind]);
			}
			else
			{
				ind = SET.find_by_order((SIZE-1)/2)->S;
				cnt_left = SIZE/2 - 1;
				cnt_right = SIZE/2;
				left = query(1,1,cnt_upd_queries,1,mapp[ind]-1);
				right = query(1,1,cnt_upd_queries,mapp[ind]+1,cnt_upd_queries);
				ans = (cnt_left*arr[ind] - left) + (right - cnt_right*arr[ind]);
			}
			// cout << "pre ans : " << ans << " " << sum << " : " << ind << '\n';
			ans += sum;
			cout << arr[ind] << " " << ans << '\n';
		}
		else
		{
			x = queries[i][1];
			y = queries[i][2];
			ind = queries[i][3];
			sum += y;
			SET.insert({x,ind});
			arr[ind] = x;
			// cout << "qu : " << x << " " << y << " " << ind << " " << arr[ind] << '\n';
			update(1,1,cnt_upd_queries,mapp[ind],x);
		}
	}
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(9);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 43264