n = gets.to_i
h = Hash.new(0)
(1..n).each do
    x, y = gets.split.map(&:to_i)
    t = x + y
    loop do
        h[t] += 1
        if h[t] == 2
            h.delete(t)
            t += 1
        else
            break
        end
    end
end
h.keys.sort.each {|k| puts "#{k} 0"}
