#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007 
#define pb push_back
//#define mp make_pair
#define INF 2000000011LL
#define INFLL 1000000000000000011LL
#define eps 1e-9
#define pp pair < pair<ll,ll> , ll> 
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define foll(i,j,k) for(ll i=j;i<=k;i++)
#define clr(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vll vector<ll>
#define sz(a) a.size()
#define len(a) a.length()
#define all(a) a.begin(),a.end()
#define io_file freopen("Contest/input_file.in", "r", stdin); freopen("Contest/output_file.in", "w", stdout)

const int MAXN = 2e5+5;
using namespace std;
ll power(ll x, ll y)
{
  ll res = 1;
  while(y>0)
  {
    if(y&1)
       {
         res = (res*x)%mod;
        }
     x = (x*x)%mod;
     y = y>>1;
  }
    return res;
}
// std::vector<ll> divi[100004];
// void divisor(int n)
// {
//    for(ll i=1;i<=n;i++)
//    {
//      for(ll j=i;j<=n;j+=i)
//      {
//        divi[j].pb(i);
//      }
//    }
// }
ll n,m,k;
priority_queue<ll,vector<ll>,greater<ll>>g;
priority_queue<ll>s;
ll sumg, sums;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    ll len = 0;
    ll val = 0;
    ll med = 0;
    n--;
    int type;
    ll x,b;
    cin>>type>>x>>b;
    g.push(x);
    val = b;
    med = x;
    sumg = x;
    while(n--)
    {
      int type;
      cin>>type;
      if(type==1)
      {
        ll x,b;
        cin>>x>>b;
        val = val + b;
        len++;
        if (s.size() > g.size()) 
        { 
            if (x < med) 
            { 
                g.push(s.top());
                sumg = sumg + s.top();
                sums = sums - s.top(); 
                s.pop(); 
                s.push(x); 
                sums = sums + x;
            } 
            else
                g.push(x), sumg = sumg  + x; 
  
            med = (s.top() + g.top())/2; 
        } 
  
        // case2(both heaps are balanced) 
        else if (s.size()==g.size()) 
        { 
            if (x < med) 
            { 
                s.push(x); 
                sums = sums + x;
                med = s.top(); 
            } 
            else
            { 
                g.push(x); 
                sumg = sumg + x;
                med = g.top(); 
            } 
        } 
  
        // case3(right side heap has more elements) 
        else
        { 
            if (x > med) 
            { 
                s.push(g.top());
                sums = sums + g.top();
                sumg = sumg - g.top(); 
                g.pop(); 
                g.push(x); 
                sumg = sumg + x;
            } 
            else
                s.push(x), sums = sums + x; 
  
              med = (s.top() + g.top())/2LL; 
        } 

      }
      else{
        // cout<<"sum is "<<sumg<<" "<<sums<<endl;
        ll left = g.size();
        ll right = s.size();
        // cout<<"lengths are "<<left<<" "<<right<<endl;
        
        // cout<<"val is "<< val<<endl;
        if(s.size()  > g.size())
        {
          med = s.top();
        }
        else if(s.size()==g.size())
        {
          med = s.top();
        }
        else{
          med = g.top();
        }
        ll y = sumg - left*med +  med*right - sums + val;
        
        cout<<med<<" "<<y<<endl;
      }
    }
    return 0;

}



Measured memory_bytes: 3828