#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int qq;
  cin >> qq;
  priority_queue<int> lo;
  priority_queue<int, vector<int>, greater<int>> hi;
  long long sum = 0, sum_lo = 0, sum_hi = 0;
  while (qq--) {
    int x;
    cin >> x;
    if (x == 2) {
      long long t = lo.top();
      cout << lo.top() << " " << sum + t * (int) lo.size() - sum_lo + sum_hi - t * (int) hi.size() << '\n';
    } else {
      int a, b;
      cin >> a >> b;
      sum += b;
      if (lo.empty() || a <= lo.top()) {
        lo.push(a);
        sum_lo += a;
        if ((int) lo.size() > (int) hi.size() + 1) {
          int t = lo.top();
          lo.pop();
          sum_lo -= t;
          sum_hi += t;
          hi.push(t);
        }
      } else {
        sum_hi += a;
        hi.push(a);
        if ((int) hi.size() > (int) lo.size()) {
          int t = hi.top();
          hi.pop();
          sum_lo += t;
          sum_hi -= t;
          lo.push(t);
        }
      }
    }
  }
  return 0;
}