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


public class F
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int Q = GetInt();

		var ql = new PriorityQueue<long>(Q, (x, y) => y.CompareTo(x));
		var qr = new PriorityQueue<long>(Q, (x, y) => x.CompareTo(y));
		long INF = long.MaxValue;
		ql.Push(-INF);
		qr.Push(INF);

		var ans = new StringBuilder();
		long sumA = 0;
		long sumB = 0;
		for(int i = 0; i < Q; i++)
		{
			int mode = GetInt();
			if(mode == 2)
			{
				ans.AppendFormat($"{ql.Peek()} {sumA + sumB}\n");
				continue;
			}

			long a = GetLong();
			long b = GetLong();
			sumB += b;
			if(ql.Size == qr.Size)
			{
				if(a < ql.Peek() || a > qr.Peek())
					sumA += Math.Min(Math.Abs(a - ql.Peek()), Math.Abs(a - qr.Peek()));
			}
			else
			{
				sumA += Math.Abs(ql.Peek() - a);
			}

			if(a < ql.Peek())
				ql.Push(a);
			else
				qr.Push(a);

			if(qr.Size > ql.Size)
			{
				ql.Push(qr.Peek());
				qr.Pop();
			}
			else if(ql.Size > qr.Size + 1)
			{
				qr.Push(ql.Peek());
				ql.Pop();				
			}
		}

		Console.Write(ans);
	}
}

public class PriorityQueue<T>
{
	public long Size { get; private set; } = 0;
	public long MaxSize { get; private set; } = 0;
	private T[] m_heap;
	private Comparison<T> Comp = null;
	
	public PriorityQueue(long maxSize, Comparison<T> comp)
	{
		if(maxSize <= 0)
			throw new Exception();
		MaxSize = maxSize;
		m_heap = new T[maxSize];

		Comp = comp;
	}
	
	public void Push(T x)
	{
		if(Size == MaxSize)
		{
			T[] new_heap = new T[MaxSize << 1];
			Array.Copy(m_heap, new_heap, MaxSize);
			m_heap = new_heap;
			MaxSize <<= 1;
		}
		
		long i = Size++;
		while(i > 0)
		{
			long p = (i - 1)/2;
			if(Comp(m_heap[p], x) <= 0)
				break;
			m_heap[i] = m_heap[p];
			i = p;			
		}
		m_heap[i] = x;		
	}
	
	public T Pop()
	{
		if(Size == 0)
			throw new Exception("Queue is empty.");
		
		T result = m_heap[0];
		T x = m_heap[--Size];
		long i = 0;
		while(i * 2 + 1 < Size)
		{
			long c1 = i * 2 + 1, c2 = i * 2 + 2;
			if(c2 < Size && Comp(m_heap[c2], m_heap[c1]) < 0)
				c1 = c2;
			if(Comp(m_heap[c1], x) >= 0)
				break;
			m_heap[i] = m_heap[c1];
			i = c1;
		}
		m_heap[i] = x;
		
		return result;		
	}

	public T Peek() => m_heap[0];
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 29076