#include <cstdio>
#include <functional>
#include <vector>
#include <queue>

int main(){
  int Q;
  scanf("%d", &Q);

  std::priority_queue<long> ls;
  std::priority_queue<long, std::vector<long>, std::greater<long>> rs;
  long qs,a,b;
  scanf("%ld%ld%ld", &qs, &a, &b);
  ls.push(a);
  rs.push(a);
  long min_val = b;
  for(int qi = 0; qi < Q-1; qi++){
    scanf("%ld", &qs);
    if(qs == 1){
      scanf("%ld%ld", &a, &b);
      auto lend = ls.top();
      auto rbegin = rs.top();
      if(a < lend){
        ls.pop();
        rs.push(lend);
        ls.push(a); ls.push(a);
        min_val += lend-a+b;
      }else if(a > rbegin){
        rs.pop();
        ls.push(rbegin);
        rs.push(a); rs.push(a);
        min_val += a-rbegin+b;
      }else{
        ls.push(a); rs.push(a);
        min_val += b;
      }
    }else{
      printf("%ld %ld\n", ls.top(), min_val);
    }
  }

  return 0;
}

