#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef vector<long long int> vi;
typedef pair<int,int> pi;


string to_string(string s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string) s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(char ch) {
	return string("'")+ch+string("'");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <class InputIterator>
string to_string (InputIterator first, InputIterator last) {
	bool start = true;
	string res = "{";
	while (first!=last) {
		if (!start) {
			res += ", ";
		}
		start = false;
		res += to_string(*first);
		++first;
	}
	res += "}";
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto &x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}";
	return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x){
	input>>x.F>>x.S;
	return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x){
	for(auto& i:x)
		input>>i;
	return input;
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif



const int mod=998244353;

int mul(int a,int b)
{
	return (a*1ll*b)%mod;
	}
	
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
	}
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
		}
	return res;
	}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=300005;

#define int ll
   
void solve(){
int q;
cin>>q;
int sum_right=0,sum_left=0,constant=0;
priority_queue<int,vi,greater<ll>>right;
priority_queue<int>left;
while(q--)
{
	int nm;
	cin>>nm;
	if(nm==1)
	{
		int a,b;
		cin>>a>>b;
		constant+=b;
		if(left.size()<right.size())
		{
			if(right.top()>=a)
			{
				left.push(a);
				sum_left+=a;
				}
			else
			{
				int tp=right.top();
				right.pop();
				sum_right-=tp;
				sum_left+=tp;
				sum_right+=a;
				right.push(a);
				left.push(tp);
				}
			}
		else
		{
		if(left.size()&&left.top()>a)
		{
		int tp=left.top();
		sum_left-=tp;
		sum_right+=tp;
		left.pop();
		left.push(a);
		sum_left+=a;
		right.push(tp);	
			}
		else
		{
			sum_right+=a;
			right.push(a);
			}
		
		
			}
		}
	else
	{
		int numbers=left.size()+right.size();
		if(numbers==0)cout<<0<<' '<<0<<"\n";
		else if(numbers%2==0){
		//	debug(sum_left,sum_right,constant);
		cout<<min(left.top(),right.top())<<' '<<-sum_left+sum_right+constant<<"\n";	
			}
		else{
				
				cout<<right.top()<<' '<<-sum_left+sum_right+constant-right.top()<<"\n";
				
				}
		
		}
	
	}
}
	

signed main()
{   
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tc=1;
	//cin>>tc;
	
    for(int i=0;i<tc;i++)
	{
		//cout<<"Case #"<<i+1<<": "; 
        solve();
		}
	
	}
/* Intuition > Logic 
 * If you are not confident please dont submit
 * When you feel like Quitting: Remember why you started
 * Game Theory == Skip
 * If n== 1e18 apply binary or Matrix expo

 *  I see those tears in your eyes
   I feel so helpless inside
   Oh love, there's no need to hide
   Just let me love you when your heart is tired
   Cold hands, red eyes
   Packed your bags at midnight
   They've been there for weeks
   You don't know what goodbye means
   Just roll up a cigarette
   Just forget about this mess
   Waiting on the sidelines
   From the sidelines
 */


Measured memory_bytes: 3828