using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var Q = consoleReader.Int();
            var result = new List<string>(Q);
            var sorted = new SortedCollection();

            long left = 0;
            long right = 0;
            long bottom = 0;
            foreach (var query in consoleReader.RepeatSplitInt(Q))
            {
                if (query[0] == 1)
                {
                    var item = query[1];
                    bottom += query[2];
                    var insertIndex = sorted.Add(item);
                    var halfIndex = sorted.Count / 2;
                    if (sorted.Count % 2 == 0)
                    {
                        if (insertIndex < halfIndex)
                        {
                            left += item;
                            right += sorted[halfIndex];
                        }
                        else
                        {
                            left += sorted[halfIndex - 1];
                            right += item;
                        }
                    }
                    else
                    {
                        if (insertIndex < halfIndex)
                        {
                            left += item - sorted[halfIndex];
                        }
                        else if (insertIndex > halfIndex)
                        {
                            right += item - sorted[halfIndex];
                        }
                    }
                }
                else
                {
                    long sum = bottom + right - left;
                    result.Add($"{sorted[(sorted.Count - 1) / 2]} {sum}");
                }
            }

            return MultiLine(result);
        }

        class SortedCollection : List<int>
        {
            public new int Add(int item)
            {
                if (this.Count == 0)
                {
                    base.Add(item);
                    return 0;
                }

                int start = 0;
                int end = this.Count;
                while (start != end)
                {
                    var half = (start + end) / 2;
                    if (item < this[half])
                    {
                        end = half;
                    }
                    else
                    {
                        start = half + 1;
                    }
                }

                Insert(start, item);
                return start;
            }
        }

        public const int mod = 1000000007;
        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc()); static string MultiLine<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

    #region Console
    public class ConsoleReader { public virtual string String() => Console.ReadLine(); public int Int() => int.Parse(String()); public long Long() => long.Parse(String()); public ulong ULong() => ulong.Parse(String()); public double Double() => double.Parse(String()); public string[] Split() => String().Split().ToArray(); public int[] SplitInt() => String().Split().Select(int.Parse).ToArray(); public long[] SplitLong() => String().Split().Select(long.Parse).ToArray(); public ulong[] SplitULong() => String().Split().Select(ulong.Parse).ToArray(); public double[] SplitDouble() => String().Split().Select(double.Parse).ToArray(); public IEnumerable<string> Repeat(int count) { for (int i = 0; i < count; i++) yield return String(); } public IEnumerable<int> RepeatInt(int count) { for (int i = 0; i < count; i++) yield return Int(); } public IEnumerable<long> RepeatLong(int count) { for (int i = 0; i < count; i++) yield return Long(); } public IEnumerable<string[]> RepeatSplit(int count) { for (int i = 0; i < count; i++) yield return Split(); } public IEnumerable<int[]> RepeatSplitInt(int count) { for (int i = 0; i < count; i++) yield return SplitInt(); } }
    #endregion
}

Measured memory_bytes: 36556