#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll LINF = 1e18;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"[";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"]";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&p)
{o<<"{"<<p.first<<", "<<p.second<<"}";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj)
{o<<"{";for(auto itr=obj.begin();itr!=obj.end();++itr)o<<(itr!=obj.begin()?", ":"")<<*itr;o<<"}";return o;}


int main()
{
  int Q,t,a,b;
  ll min=0,minx=0;
  cin >> Q;
  priority_queue<int> L,R;
  cin >> t >> a >> b;
  L.push(a);
  R.push(b);
  minx = a;
  min = b;

  for(int i=0; i<Q-1; i++){
    cin >> t;
    if(t == 1){
      int x,y;
      x = L.top();
      y = R.top();
      cin >> a >> b;
      min += b+abs(minx-a);
      if(a < x){
        L.pop();
        R.push(x);
        L.push(a);
        L.push(a);
        int k = L.top();
        minx = k;
      }else if (a > y){
        R.pop();
        L.push(y);
        R.push(a);
        R.push(a);
        int newx = L.top();
        min += (newx-minx);
        minx = newx;
      }else{
        L.push(a);
        R.push(a);
        int newx = L.top();
        min += (newx-minx);
        minx = newx;
      }
    }else{
      cout << minx << " " << min << endl;
    }
  }
  return 0;
}
