def inp() a=gets.chomp.split(" ").map(&:to_i)end def inpf() a=gets.chomp.split(" ").map(&:to_f)end def inps() a=gets.chomp.split(" ")end def copy(a) Marshal.load(Marshal.dump(a)) end def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end def scount(a,b) a.each{|n|b[n]+=1} end def na(n,d=0) Array.new(n,d)end def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end def oppai(r) ans = 1 if(r == 1) return @ue elsif(r%2 == 0) ans *= oppai(r/2) ans *= oppai(r/2) keta = ans.to_s.size-1 if(keta > 3) ans /= 10**(keta-1) @keta += (keta-1) end return ans else ans *= oppai(r-1) ans *= oppai(1) keta = ans.to_s.size-1 if(keta > 3) ans /= 10**(keta-1) @keta += (keta-1) end return ans end end n = inp[0] n.times do a,b = inp keta = (a.to_s.size) -1 @keta = keta * b if(keta > 0) @ue = a / keta else @ue = a end ue = oppai(b) keta = @keta + ue.to_s.size - 1 puts "#{ue.to_s[0]} #{ue.to_s[1]} #{keta}" end