#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <numeric>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const int mod = 1000000007;
const ll MOD = 1000000007;
const ll INF = 1LL << 60;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
   for (auto &v : vec)
      is >> v;
   return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec)
{
   os << "[";
   for (auto v : vec)
      os << v << ",";
   os << "]";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const deque<T> &vec)
{
   os << "deq[";
   for (auto v : vec)
      os << v << ",";
   os << "]";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_set<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_multiset<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{
   os << "(" << pa.first << "," << pa.second << ")";
   return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const map<TK, TV> &mp)
{
   os << "{";
   for (auto v : mp)
      os << v.first << "=>" << v.second << ",";
   os << "}";
   return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp)
{
   os << "{";
   for (auto v : mp)
      os << v.first << "=>" << v.second << ",";
   os << "}";
   return os;
};
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
   fill((T *)array, (T *)(array + N), val);
}


// struct BIT
// {
//     int n;
//     vector<int> bit;
//     BIT()
//     {
//         init();
//     }
//     BIT(int n) : n(n)
//     {
//         init();
//     }
//     void init()
//     {
//         bit.clear();
//         bit.resize(n + 1, 0);
//     }
//     int sum(int i)
//     {
//         int s = 0;
//         while (i > 0)
//         {
//             s += bit[i];
//             i -= i & -i;
//         }
//         return s;
//     }
//     int sum(int x, int y)
//     {
//         return sum(y) - sum(x - 1);
//     }
//     int sum2(int x, int y)
//     {
//        return sum(y-1) - sum(x - 1);
//     }
//     void add(int i, int x)
//     {
//        if(i == 0)
//           return;
//         while (i <= n)
//         {
//            bit[i] += x;
//            i += i & -i;
//         }
//     }

//     int lower_bound(int w)
//     {
//         if (w <= 0)
//             return 0;
//         int x = 0, r = 1;
//         while (r < n)
//             r <<= 1;
//         for (int k = r; k > 0; k >>= 1)
//         {
//             if (x + k <= n && bit[x + k] < w)
//             {
//                 w -= bit[x + k];
//                 x += k;
//             }
//         }
//         return x + 1;
//     }
// };

template <typename T>
struct BIT
{
   int n;
   vector<T> dat;

   BIT(int n = 0)
   {
      initialize(n);
   }

   void initialize(int nin)
   {
      n = nin;
      dat.resize(n);
      for (int i = 0; i < n; i++)
         dat[i] = 0;
   }

   T sum(int i)
   {
      T s = 0;
      while (i >= 0)
      {
         s += dat[i];
         i = (i & (i + 1)) - 1;
      }
      return s;
   }

   T sum2(int i, int j)
   {

      return sum(j-1) - sum(i - 1);
   }

   void add(int i, T x)
   {
      while (i < n)
      {
         dat[i] += x;
         i |= i + 1;
      }
   }

   // a[0]+...+a[ret] >= x
   int lower_bound(T x)
   {
      int ret = -1;
      int k = 1;
      while (2 * k <= n)
         k <<= 1;
      for (; k > 0; k >>= 1)
      {
         if (ret + k < n && dat[ret + k] < x)
         {
            x -= dat[ret + k];
            ret += k;
         }
      }
      return ret + 1;
   }
};

ll a[202020], b[202020];
int solve()
{
   ll n;
   cin >> n;
   vector<ll> que(n);
   vector<ll> at;

   for(int i=0; i < n; i++){
      cin >> que[i];
      if(que[i] == 1){
         cin >> a[i] >> b[i];
         at.push_back(a[i]);
      }
   }
   //座標圧縮

   sort(at.begin(), at.end());
   at.erase(unique(at.begin(), at.end()), at.end());
   map<ll,ll> m;
   ll pre = INF,cnt=0;
   for(int i=0; i < at.size(); i++){
      // if(pre == a[i]) continue;
      // m[at[i]] = cnt;
      // cnt++;
      // pre = at[i];
      m[at[i]] = i;
   }
   ll K = at.size();

   BIT<ll> bit_count(K);
   BIT<ll> bit_value(K);
   ll B = 0;
   cnt = 0;
   //cout << at << endl;
   for(int i=0; i < n; i++){
      if (que[i] == 1)
      {
         bit_count.add(m[a[i]], 1);
         bit_value.add(m[a[i]], a[i]);
         B += b[i];
         cnt++;
      }else{
         ll index = bit_count.lower_bound((cnt+1)/2);
         //dbg(index);
         ll ans = bit_value.sum2(index+1,K) + at[index]*bit_count.sum2(0,index) 
         - bit_value.sum2(0,index) -  at[index]*bit_count.sum2(index +1,K);
         cout << at[index] << " " << ans + B << endl;
      }
   }




   return 0;
}

int main()
{
   //cout.precision(10)
   ios::sync_with_stdio(false);
   cin.tie(0);

   solve();
}

Measured memory_bytes: 15860