class Calc0219 def initialize(args) args = args.map { |l| l.chomp.split(/\s+/) } @n = args.shift.first.to_i @ps = args.map { |l| l.map(&:to_i) } end def run @ps.map { |a, b| c = b * Math.log10(a) z = c.floor w = 10 ** (c - z) x = w.floor y = ((w - x) * 10).to_i [x, y, z].join(' ') } end end puts Calc0219.new(STDIN.readlines).run if __FILE__ == $0