def ascan; gets.split.map(&:to_i); end def scan; gets.to_i; end a = gets.chomp f = false "a".upto("m"){|c| b = (a+c).chars.sort h = {} b.each{|e| h[e]||=0; h[e]+=1} j = {} h.values.each{|e| j[e]||=0; j[e]+=1} if j[1] == 12 && j[2] == 1 puts c f = true end } unless f puts "Impossible" end