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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

bool in(string s1, string s2) {
  int64 idx = 0;
  REP(i, s2.size()) {
    if (idx < s1.size() && s1[idx] == s2[i]) idx++;
  }
  return idx == s1.size();
}

::std::vector<::std::int64_t> divisors(::std::int64_t x) {
	::std::vector<::std::int64_t> res;
	for (::std::int64_t i = 1; i*i <= x; ++i) {
		if (x % i == 0) {
			res.push_back(i);
			if (i * i != x) res.push_back(x / i);
		}
	}
	::std::sort(res.begin(), res.end());
	return res;
}

template<::std::uint_fast64_t mod>
class ModInt{
private:
	using value_type = ::std::uint_fast64_t;
	value_type n;
public:
	ModInt() : n(0) {}
	ModInt(value_type n_) : n(n_ % mod) {}
	ModInt(const ModInt& m) : n(m.n) {}

	template<typename T>
	explicit operator T() const { return static_cast<T>(n); }
	value_type get() const { return n; }

	friend ::std::ostream& operator<<(::std::ostream &os, const ModInt<mod> &a) {
		return os << a.n;
	}

	friend ::std::istream& operator>>(::std::istream &is, ModInt<mod> &a) {
		value_type x;
		is >> x;
		a = ModInt<mod>(x);
		return is;
	}

	bool operator==(const ModInt& m) const { return n == m.n; }
	bool operator!=(const ModInt& m) const { return n != m.n; }
	ModInt& operator*=(const ModInt& m){ n = n * m.n % mod; return *this; }

	ModInt pow(value_type b) const{
		ModInt ans = 1, m = ModInt(*this);
		while(b){
			if(b & 1) ans *= m;
			m *= m;
			b >>= 1;
		}
		return ans;
	}

	ModInt inv() const { return (*this).pow(mod-2); }
	ModInt& operator+=(const ModInt& m){ n += m.n; n = (n < mod ? n : n - mod); return *this; }
	ModInt& operator-=(const ModInt& m){ n += mod - m.n; n = (n < mod ? n : n - mod); return *this; }
	ModInt& operator/=(const ModInt& m){ *this *= m.inv(); return *this; }
	ModInt operator+(const ModInt& m) const { return ModInt(*this) += m; }
	ModInt operator-(const ModInt& m) const { return ModInt(*this) -= m; }
	ModInt operator*(const ModInt& m) const { return ModInt(*this) *= m; }
	ModInt operator/(const ModInt& m) const { return ModInt(*this) /= m; }
	ModInt& operator++(){ n += 1; return *this; }
	ModInt& operator--(){ n -= 1; return *this; }
	ModInt operator++(int){
		ModInt old(n);
		n += 1;
		return old;
	}
	ModInt operator--(int){
		ModInt old(n);
		n -= 1;
		return old;
	}
	ModInt operator-() const { return ModInt(mod-n); }
};

template<::std::size_t size, ::std::uint_fast64_t mod=1000000007>
class Factorial{
private:
	using value_type = ModInt<mod>;
	::std::vector<value_type> fact, inv;
public:
	Factorial() : fact(size+1, 1), inv(size+1, 1){
		for(::std::size_t i = 1; i <= size; ++i){
			fact[i] = fact[i-1] * value_type(i);
			inv[i] = fact[i].inv();
		}
	}

	value_type comb(::std::int64_t a, ::std::int64_t b){
		assert(a >= b);
		assert(b >= 0);
		return fact[a]*inv[b]*inv[a-b];
	}

	value_type& operator[](::std::size_t k){ return fact[k]; }
};

template<class ValueMonoid, class OperatorMonoid,
	class Modifier, ::std::size_t NODE_NUM=1000000>
class Treap{
public:
	using value_structure = ValueMonoid;
	using value_type = typename value_structure::value_type;
	using operator_structure = OperatorMonoid;
	using operator_type = typename operator_structure::value_type;
	using modifier = Modifier;
	using size_type = ::std::size_t;

private:
	class Node{
	public:
//		using pointer = ::std::shared_ptr<Node>;
		using pointer = Node*;
		value_type v, acc;
		operator_type lazy;
		pointer lch, rch;
		size_type size, pri;

		Node()
			: v(value_structure::identity()), lazy(operator_structure::identity()),
				pri(0), size(1), acc(value_structure::identity()){}

		Node(value_type v, size_type pri):
			v(v), lazy(operator_structure::identity()), pri(pri), size(1), acc(v){
			lch = rch = nullptr;
		}
	};

	static size_type xorshift(){
		static size_type x = 123456789, y = 362436069, z = 521288629, w = 88675123;
		size_type t = (x ^ (x << 11));
		x = y; y = z; z = w;
		return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
	}

public:
//	using pointer = ::std::shared_ptr<Node>;
	using pointer = Node*;

private:
	pointer root;

	static void apply(pointer p, const operator_type x){
		p->lazy = operator_structure::operation(p->lazy, x);
		p->acc = modifier::operation(p->acc, p->lazy, count(p));
	}

public:
	Treap() : root(nullptr) {}
	Treap(pointer p) : root(p) {}

	static size_type count(pointer p){
		return p == nullptr ? 0 : p->size;
	}
	static value_type query(pointer p){
		return p == nullptr ? value_structure::identity() : p->acc;
	}

	static pointer eval(pointer p){
		if(p->lazy != operator_structure::identity()){
			p->v = modifier::operation(p->v, p->lazy, 1);
			if(p->lch != nullptr){
				apply(p->lch, p->lazy);
			}
			if(p->rch != nullptr){
				apply(p->rch, p->lazy);
			}
			p->lazy = operator_structure::identity();
		}
		return update(p);
	}

	static pointer update(pointer p){
		p->size = count(p->lch) + count(p->rch) + 1;
		p->acc = value_structure::operation(
				value_structure::operation(query(p->lch), p->v),
				query(p->rch));
		return p;
	}

	static pointer merge(pointer l, pointer r){
		if(l == nullptr || r == nullptr)
			return l == nullptr ? r : l;
		if(l->pri > r->pri){
			l = eval(l);
			l->rch = merge(l->rch, r);
			return update(l);
		}else{
			r = eval(r);
			r->lch = merge(l, r->lch);
			return update(r);
		}
	}

	static ::std::pair<pointer, pointer> split(pointer p, size_type k){
		if(p == nullptr) return ::std::make_pair(nullptr, nullptr);

		p = eval(p);
		if(k <= count(p->lch)){
			::std::pair<pointer, pointer> ret = split(p->lch, k);
			p->lch = ret.second;
			return ::std::make_pair(ret.first, update(p));
		}else{
			::std::pair<pointer, pointer> ret = split(p->rch, k - count(p->lch) - 1);
			p->rch = ret.first;
			return ::std::make_pair(update(p), ret.second);
		}
	}

	static Treap merge(Treap l, Treap r){
		return Treap(merge(l.root, r.root));
	}

	::std::pair<Treap, Treap> split(size_type k){
		::std::pair<pointer, pointer> ret = split(root, k);
		return ::std::make_pair(Treap(ret.first), Treap(ret.second));
	}

	void insert(size_type k, const value_type v, size_type pri=xorshift()){
		if(root == nullptr){
			root = create_node(v, pri);
			return;
		}
		pointer l, r;
		::std::tie(l, r) = split(root, k);
		root = merge(l, create_node(v, pri));
		root = merge(root, r);
	}

	value_type erase(size_type k){
		Treap l, _, r;
		::std::tie(l, r) = split(k+1);
		::std::tie(l, _) = l.split(k);
		root = merge(l.root, r.root);
		return _.root->v;
	}

  size_type index(pointer p, value_type k) { // the number of node whose value <= k
    if (p == nullptr) return 0;
    if (p->v <= k) return index(p->rch, k) + count(p->lch) + 1;
    else return index(p->lch, k);
  }

  size_type index(value_type k) {
    return index(root, k);
  }

	value_type kth_element(const size_type k){
		Treap l, _, r;
		value_type ret;
		::std::tie(l, r) = split(k);
		::std::tie(l, _) = l.split(k-1);
		ret = query(_.root);
		root = merge(l.root, merge(_.root, r.root));
		return ret;
	}

	value_type query(const size_type first, const size_type last){
		Treap l, m, r;
		value_type ret;
		::std::tie(l, r) = split(last);
		::std::tie(l, m) = l.split(first);
		ret = query(m.root);
		root = merge(l.root, merge(m.root, r.root));
		return ret;
	}

	void update(const size_type first, const size_type last, const operator_type a){
		Treap l, m, r;
		::std::tie(l, r) = split(last);
		::std::tie(l, m) = l.split(first);
		apply(m.root, a);
		root = merge(l.root, merge(m.root, r.root));
	}

	template<class InputIterator>
	void insert_from_iterator(InputIterator first, InputIterator last, size_type k=-1){
		for(InputIterator itr = first; itr != last ; ++itr){
			if(k == -1){
				insert(count(root), *itr);
			}else{
				insert(k++, *itr);
			}
		}
	}
/*
	pointer create_node(const value_type v, size_type pri){
		return ::std::make_shared<Node>(Node(v, pri));
	}
	*/

	static pointer create_node(const value_type v, size_type pri){
		static Node pool[NODE_NUM];
		static size_type ptr = 0;
		return &(pool[ptr++]=Node(v, pri));
	}

	void dump(pointer p, typename ::std::vector<value_type>::iterator itr){
		if(p == nullptr) return;
		p = eval(p);
		dump(p->lch, itr);
		*(itr+count(p->lch)) = p->v;
		dump(p->rch, itr+count(p->lch)+1);
	}

  ::std::vector<value_type> dump(pointer p=nullptr){
		if(p == nullptr) p = root;
    ::std::vector<value_type> v(count(p));
    dump(p,v.begin());
    return v;
  }
};

class v_monoid {
public:
  using value_type = int64;
  static value_type identity() { return 0; }
  static value_type initializer() { return 0; }
  static value_type operation(const value_type& a, const value_type& b) {
    return a + b;
  }
};

class o_monoid {
public:
  using value_type = int64;
  static value_type identity() { return 0; }
  static value_type operation(const value_type& a, const value_type& b) {
    return a + b;
  }
};

class modifier {
public:
  using value_type = int64;
  static value_type operation(const value_type& a, const value_type& b, int64 x) {
    return a + b;
  }
};

const int64 mod = 1e9+7;
using Mint = ModInt<mod>;
Factorial<412345> f;

int main(void) {
  int64 Q;
  cin >> Q;
  int64 c = 0;
  using T = tuple<int64, int64, int64>;
  vector<T> q(Q);
  vector<int64> v;
  Treap<v_monoid, o_monoid, modifier> tr;
  int64 cnt = 0;
  REP(i, Q) {
    int64 t;
    cin >> t;
    if (t == 1) {
      cnt++;
      int64 a, b;
      cin >> a >> b;
      c += b;
      int64 k = tr.index(a);
      tr.insert(k, a);
    } else {
      int64 ret = 0;
      int64 v = tr.kth_element((cnt+1)/2);
      ret += v*((cnt+1)/2) - tr.query(0, (cnt+1)/2);
      ret += tr.query((cnt+1)/2, cnt) - v * (cnt/2);
      cout << v << " " << ret+c << endl;
    }
  }
  // sort(all(v));
  // v.erase(unique(all(v)));
  // map<int64, int64> zip;
  // REP(i, v.size()) zip[v[i]] = i;
  
}

Measured memory_bytes: 68608