using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var SHL = new SkewHeap<long>();
		var SHR = new SkewHeap<long>();
		long ltot = 0, rtot = 0;
		int cnt = 0;
		
		long btot = 0;
		for(int q=0;q<Q;q++){
			switch(Query[q][0]){
				case 1:{
					cnt++;
					long a = Query[q][1];
					long b = Query[q][2];
					btot += b;
					
					int lc = (cnt + 1) / 2;
					int rc = cnt - lc;
					
					if(SHL.Count == 0){
						SHL.Push(-a);
						ltot += a;
						break;
					} else if(SHR.Count == 0){
						SHL.Push(-a);
						ltot += a;
						var na = SHL.Top * -1; SHL.Pop();
						ltot -= na;
						SHR.Push(na);
						rtot += na;
						break;
					} else {
						var la = SHL.Top * -1;
						var lb = SHR.Top;
						if(a <= la){
							SHL.Push(-a);
							ltot += a;
						} else {
							SHR.Push(a);
							rtot += a;
						}
						while(SHL.Count > lc){
							var x = SHL.Top * -1;SHL.Pop();
							ltot -= x;
							SHR.Push(x);
							rtot += x;
						}
						while(SHR.Count > rc){
							var x = SHR.Top ;SHR.Pop();
							rtot -= x;
							SHL.Push(-x);
							ltot += x;
						}
					}
				} break;
				case 2:{
					if(SHL.Count > SHR.Count){
						long x = SHL.Top * -1;
						long left = (SHL.Count - 1) * x - (ltot - x);
						long right = - x * SHR.Count + rtot;
						Console.WriteLine("{0} {1}",x, left + right + btot); 
					} else {
						long x = SHL.Top * -1;
						long left = (SHL.Count - 1) * x - (ltot - x);
						long right = - x * SHR.Count + rtot;
						Console.WriteLine("{0} {1}",x, left + right + btot); 
					}
					
				} break;
				
			}
		}
	}
	int Q;
	long[][] Query;
	public Sol(){
		Q = ri();
		Query = new long[Q][];
		for(int i=0;i<Q;i++){
			Query[i] = rla();
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


class SkewHeap<T> where T:IComparable<T>{
	public int Count{
		get{return cnt;}
		private set{cnt=value;}
	}
	
	public SkewHeap(){
		root=null;
		this.Count=0;
	}
	
	public void Push(T v){
		NodeSH<T> p=new NodeSH<T>(v);
		root=NodeSH<T>.Meld(root,p);
		this.Count++;
	}
	
	public void Pop(){
		if(root==null)return;
		root=NodeSH<T>.Meld(root.L,root.R);
		this.Count--;
	}
	
	public T Top{
		get{return root.Val;}
	}
	
	int cnt;
	NodeSH<T> root;
	
	class NodeSH<S> where S : IComparable<S> {
		public NodeSH<S> L, R;
		public S Val;

		public NodeSH(S v){
			Val = v;
			L = null; R = null;
		}
		public static NodeSH<S> Meld(NodeSH<S> a, NodeSH<S> b){
			if(a == null)return b;
			if (b == null) return a;
			if (a.Val.CompareTo(b.Val) > 0) swap(ref a, ref b);
			a.R = Meld(a.R, b);
			swap(ref a.L, ref a.R);
			return a;
		}

		static void swap<U>(ref U x, ref U y) {
			U t = x; x = y; y = t;
		}
	}
}



Measured memory_bytes: 38676