T = gets.to_i target = 'helloworld' T.times do n = gets.to_i s = gets.chomp best_idx = -1 list = [] (n - 10).downto(0) do |i| ok = true idx = 0 while ok && idx < 10 if target[idx] == s[i + idx] || s[i + idx] == '?' # NOOP else ok = false end idx += 1 end if ok t = s.dup 10.times do |idx| if t[i + idx] == '?' t[i + idx] = target[idx] end end t.tr!('?', 'a') list << t end end if list.size > 0 puts list.sort[0] else puts -1 end end