Problem:
Max Score: 250 Points

Problem Statement

Mr.X, who the handle name is T, looked at the list which written N handle names, S_1, S_2, ..., S_N.

But he couldn't see some parts of the list. Invisible part is denoted ?.

Please calculate all possible index of the handle name of Mr.X when you sort N+1 handle names (S_1, S_2, ..., S_N and T) in lexicographical order.

Note: If there are pair of people with same handle name, either one may come first.

Input

The input is given from standard input in the following format.

N
S_1
S_2
:
S_N
T

Output

Calculate the possible index and print in sorted order. The output should be separated with a space. Don't print a space after last number.

Put a line break in the end.

Constraints

1 ≤ N ≤ 10000

1 ≤ |S_i|, |T| ≤ 20 (|A| is the length of A.)

S_i consists from lower-case alphabet and ?.

T consists from lower-case alphabet.

Scoring

Subtask 1 [ 130 points ]

There are no ?'s.

Subtask 2 [ 120 points ]

There are no additional constraints.

Sample Input 1

2
tourist
petr
e

Sample Output 1

1

There are no invisible part, so there are only one possibility.
The sorted handle names are e, petr, tourist, so e comes first.

Sample Input 2

2
?o?r?s?
?et?
e

Solution in Ruby (2.7.1) (judge verdict: Runtime Error)

n, k = gets.chomp.split.map(&:to_i)
buildings = gets.chomp.split.map(&:to_i)

def main(n, k, buildings)
  min = Float::INFINITY
  (0..2**n-1).each do |n_ten|
    n_two = n_ten.to_s(2).rjust(n, '0')
    extending = n_two.chars.map(&:to_i)
    next if extending.count { |flag| flag == 1 } < k

    amount = 0

    dupped_buildings = buildings.dup
    current_max = 0
    handled_buildings = dupped_buildings.map.with_index do |building, index| 
      if index == 0
        current_max = [building, current_max].max
        next building 
      end

      if extending[index] == 0
        current_max = [building, current_max].max
        next building 
      end

      if current_max < dupped_buildings[index]
        current_max = [dupped_buildings[index], current_max].max
        next dupped_buildings[index]
      else
        diff = (current_max - dupped_buildings[index]) + 1
        dupped_buildings[index] += diff
        amount += diff
        current_max = [dupped_buildings[index], current_max].max
        next dupped_buildings[index]
      end
    end

    
    amount = amount

    if amount < min
      min = amount 
    end
  end
  min 
end

puts main(n, k, buildings)