#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define ii pair<ll,ll>
#define mp make_pair
using namespace std;
int a[200005];
int b[200005];
int q[200005];
ll pre[5000005];
map < int , int > my;
int rev[5000005];
const int max_node = 10000000;
pair<ll,int> tree[max_node];
void update(int node , int start , int _end , int idx , int val)
{
    if(start == _end)
    {
        tree[node] = mp(tree[node].fr + val,tree[node].sc+1);
    }
    else
    {
        int mid = (start+_end)/2;
        if(start <= idx && idx <= mid)
        {
            update(node*2,start,mid,idx,val);
        }
        else
        {
            update(node*2+1,mid+1,_end,idx,val);
        }
        tree[node] = mp(tree[2*node].fr+tree[2*node+1].fr ,tree[2*node].sc+tree[2*node+1].sc) ;
    }
 }

pair < ll , int > query(int node , int start , int _end, int r)
{
    if(start == _end)
    {
        return tree[node];
    }
    int mid = (start+_end)/2;
    if(mid >= r)
    {
        return query(2*node  ,start , mid , r);
    }
    else
    {
        pair<ll,int> x1 = tree[node*2];
        pair<ll,int> x2 = query(2*node+1,mid+1 ,_end , r);
        return mp(x1.fr+x2.fr , x2.sc+x1.sc);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
   int n;
   cin>>n;
   int minx = 0 , maxx = 0;
   set<int> s;
   for(int i=0;i<n;i++)
   {
       int x;
       cin>>x;
       if(x == 2)
       {
           q[i] = 1;
       }
       else
       {
           cin>>a[i]>>b[i];
           s.insert(a[i]);
           s.insert(a[i]-1);
           s.insert(a[i]+1);
       }
   }
   int cnt = 1;
   pair< ll , int > All;
   for(auto x : s)
   {
       my[x] = cnt;
       rev[cnt] = x;
       cnt++;
   }
   ll ans = 0;
   for(int i=0;i<n;i++)
   {
       if(q[i] == 1)
       {
           ll st = 1,En = cnt-1;
           int idx = 1e9;
           ll temp = 1e18;
           while((En-st)>=3)
           {
               ll len = (En-st)/3;
               ll mid1 = st+len;
               ll mid2 = En-len;
               pair<ll,int> R1 = query(1,1,cnt,mid1);
               pair<ll,int> R2 = query(1,1,cnt,mid1);
               ll sum1 = 0 , sum2 = 0;
               sum1 = 1LL * rev[mid1] * R1.sc - R1.fr ;
               sum1 += 1LL * (All.fr-R1.fr) - 1LL * rev[mid1] * (All.sc-R1.sc);
               sum2 = 1LL * rev[mid2] * R2.sc - R2.fr ;
               sum2 += 1LL * (All.fr-R2.fr) - 1LL * rev[mid2] * (All.sc-R2.sc);
               if(sum1 <= sum2)
               {
                   idx = rev[mid1];
                   temp = sum1;
                   En = mid2;
               }
               else
               {
                   idx = rev[mid2];
                   temp = sum2;
                   st = mid1;
               }
           }
           if(st+1 < En)
           {
               ll mid1 = st+1;
               ll sum1 = 0;
               pair<ll,int> R1 = query(1,1,cnt,mid1);

               sum1 = 1LL * rev[mid1] * R1.sc - R1.fr ;
               sum1 += 1LL * (All.fr-R1.fr) - 1LL * rev[mid1] * (All.sc-R1.sc);
               if(sum1 < temp)
               {
                   idx = rev[mid1];
               }
               temp = min(temp , sum1);
           }
           cout<<idx<<" "<<temp+ans<<endl;
       }
       else
       {
           int f = my[a[i]];
           update(1,1,cnt,f,a[i]);
           All.fr+=a[i];
           All.sc+=1;
           ans+=b[i];
       }
   }
    return 0;
}


Measured memory_bytes: 57472