1 #!/usr/bin/env python
    2 
    3 
    4 import sys
    5 
    6 
    7 solutionLen = 1000000000
    8 solutionWeight = 1000000000
    9 solution = None
   10 
   11 def solve (str, symbols, soln='', solLen = 0, solWeight = 0):
   12     global solution
   13     global solutionWeight
   14     global solutionLen
   15     if solution == "Too Obvious":
   16         return
   17     if len(str) == 0:
   18         if solLen < solutionLen:
   19             solution = soln
   20             solutionLen = solLen
   21             solutionWeight = solWeight
   22         elif solWeight < solutionWeight:
   23             solution = soln
   24             solutionLen = solLen
   25             solutionWeight = solWeight
   26         elif solLen == solutionLen and solWeight == solutionWeight:
   27             solution = "Too Obvious"
   28             return 0
   29     for i in xrange(0,len(symbols)):
   30         s = symbols[i]
   31         if str.lower().startswith(s.lower()):
   32             solve(str[len(s):], symbols, soln + "[" + s + "]", solLen+1, solWeight + i)
   33 
   34 def solveIt(str, symbols):
   35     global solution
   36     global solutionWeight
   37     global solutionLen
   38 
   39     solutionLen = 1000000000
   40     solutionWeight = 1000000000
   41     solution = None
   42     solve(str, symbols)
   43     if solution == None:
   44         print "No Solution!"
   45     else:
   46         print solution
   47 
   48 def processCase():
   49     symbols = []
   50     numSymbols = int(sys.stdin.readline())
   51     for i in xrange(0, numSymbols):
   52         symbols.append(sys.stdin.readline().strip())
   53     numEquations = int(sys.stdin.readline())
   54     for i in xrange(0, numEquations):
   55         solveIt(sys.stdin.readline().strip(), symbols)
   56 
   57 if __name__ == "__main__":
   58     numTests = int(sys.stdin.readline())
   59     for cases in xrange(0,numTests):
   60         processCase()
   61 
   62 
   63 #solveIt('banana', symbols1)
   64 #solveIt('coke', symbols1)
   65 #solveIt('coke', symbols2)
   66 #solveIt('ass', symbols2)
   67 #solveIt('ass', symbols2)