n = gets.to_i m = 5 lim = 10 ** m n.times do |t| str = gets.split a = str[0].to_i c = b = str[1].to_i x = a.to_f q = 1.0 count = 0 xc = 0 qc = 0 while b > 0 do if b % 2 == 0 while x >= lim do x /= lim xc += m end x *= x xc += xc b >>= 1 else q *= x while q >= lim do q /= lim count += m end count += xc b -= 1 end end num = (q * 10).to_i.to_s e = count + num.length - 2 print num[0], " ", num[1], " ", e, "\n" end