#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

//
// Created by cs160 on 09-04-2019.
//
// ashishgup git

struct data {
  // Use required attributes
  int mn;
  int cnt;
  int val;

  // Default Values
  data() : mn(0), cnt(0){};
};

struct SegTree {
  int N;
  vector<data> st;
  vector<bool> cLazy;
  vector<int> lazy;

  void init(int n) {
    N = n;
    st.resize(4 * N + 5);
    cLazy.assign(4 * N + 5, false);
    lazy.assign(4 * N + 5, 0);
  }

  // Write reqd merge functions
  void merge(data &cur, data &l, data &r) {
    cur.mn = l.mn + r.mn;
    cur.cnt = l.cnt + r.cnt;
  }

  // Handle lazy propagation appriopriately
  void propagate(int node, int L, int R) {
    st[node].mn += lazy[node];
    st[node].cnt += 1;
    cLazy[node] = 0;
    lazy[node] = 0;
  }

  void build(int node, int L, int R) {
    if (L == R) {
      st[node].mn = 1e9;
      return;
    }
    int M = (L + R) / 2;
    build(node * 2, L, M);
    build(node * 2 + 1, M + 1, R);
    merge(st[node], st[node * 2], st[node * 2 + 1]);
  }
  ll Query(int node, int L, int R, int pos) {
    if (L == R) {

      ll ans = st[node].mn / st[node].cnt;
      return ans * pos;
    }
    int M = (L + R) / 2;

    ll cnt = st[node * 2].cnt;
    if (pos <= cnt)
      return Query(node * 2, L, M, pos);
    else
      return st[node * 2].mn + Query(node * 2 + 1, M + 1, R, pos - cnt);
  }

  data pQuery(int node, int L, int R, int pos) {
    if (L == R) {
      st[node].val = L;
      return st[node];
    }
    int M = (L + R) / 2;

    ll cnt = st[node * 2].cnt;
    if (pos <= cnt)
      return pQuery(node * 2, L, M, pos);
    else
      return pQuery(node * 2 + 1, M + 1, R, pos - cnt);
  }

  void pUpdate(int node, int L, int R, int pos, int val) {
    if (cLazy[node])
      propagate(node, L, R);
    if (L == R) {
      cLazy[node] = 1;
      lazy[node] = val;
      propagate(node, L, R);
      return;
    }
    int M = (L + R) / 2;
    if (pos <= M)
      pUpdate(node * 2, L, M, pos, val);
    else
      pUpdate(node * 2 + 1, M + 1, R, pos, val);
    merge(st[node], st[node * 2], st[node * 2 + 1]);
  }

  ll query(int pos) { return Query(1, 1, N, pos); }

  data PQuery(int pos) { return pQuery(1, 1, N, pos); }

  void update(int pos, int val) { pUpdate(1, 1, N, pos, val); }
};

// Problem 1 (Max Query - Point Update with Coordinate Compression):
// http://codeforces.com/gym/100733/problem/F Solution 1:
// http://codeforces.com/gym/100733/submission/41643795

// Problem 2 (Min Query - Offline processing):
// https://codeforces.com/problemset/problem/522/D Solution 2:
// https://codeforces.com/contest/522/submission/45493164

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll q;
  cin >> q;
  ll c = 0;

  ll query[q + 5][3];
  map<ll, ll> par;
  for (ll i = 1; i <= q; i++) {
    ll type;
    cin >> type;
    query[i][0] = type;
    if (type == 1) {
      ll a, b;
      cin >> a >> b;

      par[a];
      query[i][1] = a;
      query[i][2] = b;
    } else {
    }
  }
  ll cnt = 0;
  ll rm[q + 5];
  for (auto &it : par) {
    it.second = ++cnt;
    rm[cnt] = it.first;
  }

  SegTree obj;
  obj.init(q);
  c = 0;
  ll sz = 0;
  ll sum1 = 0;
  for (ll i = 1; i <= q; i++) {
    if (query[i][0] == 1) {

      ll a = query[i][1];
      c += query[i][2];
      obj.update(par[a], a);
      sz++;
      sum1 += a;
    } else {
      ll indx = sz / 2;

      ll val;

      if (indx == 0)
        val = 0;
      else
        val = obj.query(indx);

      ll cord;
      ll val2 = sum1 - val;
      if (sz & 1) {
        indx = (sz + 1) / 2;
        cord = rm[obj.PQuery(indx).val];
        val2 -= cord;
      } else {
        indx = sz / 2;
        cord = rm[obj.PQuery(indx).val];
      }

      cout << cord << " " << val2 - val + c << en;
    }
  }

  return 0;
}

Measured memory_bytes: 39424