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 C++ (GCC 9.2.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>
using namespace std;

#define ll long long

void chmin(ll& a, ll b) {
  if (a > b) a = b;
}

int main() {

  int N, K;
  cin >> N >> K;
  
  vector<ll> a(N);
  
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  
  // i番目までで最も高いもの
  vector<ll> height(N);
  height[0] = 0;
  height[1] = a[0];
  
  ll SUBMAX = a[0];
  for (int i = 1; i < N; i++) {
    if (a[i] > SUBMAX) {
      height[i] = a[i-1];
    } else {
      height[i] = SUBMAX;
    }
  }
  

  
  ll ans = 100000000000;
  
  // bit 全探索
  for (int bit = 0; bit < (1 << N); bit++) {
    ll color = 0;
    ll cost = 0;
    
    ll temp = 0; 
    for (int i = 0; i < N; i++) {
      if (bit & (1 << i)) {
        color++;

        
        if (temp >= height[i]) {
          temp++;
        } else {
          temp = height[i]+1;
        }
        
        // cost の計算
        if (i == 0) {
          temp = a[0];
          continue;
        }
        if (a[i] >= temp) {
           temp = a[i];
           continue;
        }
        cost += temp -a[i];
      }
    }
    
    if (color >= K) chmin(ans, cost);
    
  }  
  
  cout << ans << endl;

}