#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  ll q;
  cin >> q;

  multiset<ll> s;
  ll y = 0, t, a, b;
  cin >> t >> a >> b;
  s.insert(a);
  y += b;
  auto it = s.begin();
  rep(i, q - 1) {
    cin >> t;
    if (t == 1) {
      cin >> a >> b;
      s.insert(a);
      if (s.size() % 2 == 0) {
        y += abs(a - *it) + b;
        if (a < *it) it--;
      }
      else {
        if (a >= *it) it++;
        y += abs(a - *it) + b;
      }
    }
    else {
      cout << *it << " " << y << endl;
    }
  }



  



  
  return 0;
}
