/*
TASK:festa
LANG:C++
*/
#include <stdio.h>
#include <map>

struct type {
       long long coord,best;
       type() {}
       type(long long _coord,long long _best) {
                 coord = _coord;
                 best = _best;
       }
};

std::map<long long,long long> m;

void add(long long where,long long what) { m[where]+=what; }
long long abs(long long a) { return (a<0) ? -a : a; }
long long calc(long long coord) {
     long long res(0);
     for(std::map<long long,long long>::iterator it=m.begin(); it!=m.end(); ++it) {
                      res += abs(coord-(*it).first) * (*it).second; 
     }
     return res;
}
void bsl(long long cost) {
     long long l = -100000000;
     long long r = -l;
     type best;
     best.best = -1;
     while(l<r) {
                long long mid = (l+r)/2;
                long long tmp = calc(mid);
                long long nearTmp = calc(mid-1);
                if(best.best==-1) best.best=abs(cost-tmp);
                long long a1,a2;
                a2 = abs(cost-tmp);
                a1 = abs(cost-nearTmp);
                if(a1<a2) {
                   r = mid-1;
                   if(best.best>a1) {
                                    best.best = a1;
                                    best.coord = mid-1;
                   }
                }
                else {
                   l = mid+1;
                   if(best.best>a2) {
                                    best.best = a2;
                                    best.coord = mid;
                   }
                }
     }
     printf("%lld %lld\n",best.coord,best.best);
}

int main() {
    int q;
    while(scanf("%d",&q)==1) {
          if(q==1) {
            long long a,b;
            scanf("%lld %lld",&a,&b);
            add(a,b);
          }
          else { 
            long long cost;
            scanf("%lld",&cost);
            bsl(cost);
          }
    }                   
}
