#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int n; cin>>n;
  vector<ii> ans;
  priority_queue<int> qa;
  priority_queue<int, vector<int>, greater<int>> qb;
  ll p=0;
  for (int i=0; i<n; i++) {
    int x; cin>>x;
    if (x==1) {
      int a,b; cin>>a>>b;
      if (!qa.empty()&&!qb.empty() && (a<qa.top() || qb.top()<a)) {
        p += min(abs(a-qa.top()), abs(a-qb.top()));
      }
      p += b;

      qa.push(a); qb.push(a);
      int ta = qa.top();
      int tb = qb.top();
      if (ta > tb) {
        qa.pop(); qb.pop();
        qa.push(tb); qb.push(ta);
      }
    } else {
      ans.push_back(make_pair(qa.top(), p));
    }
  }

  for (int i=0; i<(int)(ans.size()); i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
}

int main()
{
  solve();
  return 0;
}
