using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("2");
WillReturn.Add("tourist");
WillReturn.Add("petr");
WillReturn.Add("e");
//1
}
else if (InputPattern == "Input2") {
WillReturn.Add("2");
WillReturn.Add("?o?r?s?");
WillReturn.Add("?et?");
WillReturn.Add("e");
//1 2 3
}
else if (InputPattern == "Input3") {
WillReturn.Add("4");
WillReturn.Add("e");
WillReturn.Add("e");
WillReturn.Add("e");
WillReturn.Add("e");
WillReturn.Add("e");
//1 2 3 4 5
}
else if (InputPattern == "Input4") {
WillReturn.Add("5");
WillReturn.Add("??");
WillReturn.Add("??");
WillReturn.Add("d?");
WillReturn.Add("?e");
WillReturn.Add("?f");
WillReturn.Add("zzz");
//6
}
else if (InputPattern == "Input5") {
WillReturn.Add("7");
WillReturn.Add("atcoder");
WillReturn.Add("topcoder");
WillReturn.Add("codeforces");
WillReturn.Add("hackerrank");
WillReturn.Add("csacademy");
WillReturn.Add("codechef");
WillReturn.Add("atcoder");
WillReturn.Add("square");
//7
}
else if (InputPattern == "Input6") {
WillReturn.Add("7");
WillReturn.Add("??i?");
WillReturn.Add("?o???g????");
WillReturn.Add("??m??x?");
WillReturn.Add("?h?????i");
WillReturn.Add("s????");
WillReturn.Add("?og????");
WillReturn.Add("u??");
WillReturn.Add("square");
//1 2 3 4 5 6 7
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main()
{
List<string> InputList = GetInputList();
int N = int.Parse(InputList[0]);
var SList = new List<string>();
foreach (string EachStr in InputList.Skip(1).Take(N)) {
SList.Add(EachStr);
}
string T = InputList.Last();
// ?を全てaにしたList
var ChangeAList = new List<string>();
// ?を全てzにしたList
var ChangeZList = new List<string>();
foreach (string EachS in SList) {
ChangeAList.Add(EachS.Replace('?', 'a'));
ChangeZList.Add(EachS.Replace('?', 'z'));
}
int MinRn = ChangeZList.Count(pX => pX.CompareTo(T) < 0) + 1;
int MaxRn = ChangeAList.Count(pX => pX.CompareTo(T) <= 0) + 1;
var AnswerList = new List<int>();
for (int I = MinRn; I <= MaxRn; I++) {
AnswerList.Add(I);
}
// セパレータとInt型の列挙を引数として、結合したstringを返す
Func<string, IEnumerable<int>, string> IntEnumJoin = (pSeparater, pEnum) =>
{
string[] StrArr = Array.ConvertAll(pEnum.ToArray(), pX => pX.ToString());
return string.Join(pSeparater, StrArr);
};
Console.WriteLine(IntEnumJoin(" ", AnswerList));
}
}