• [G] Go for a Psychological Test

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • One day, Mr. Cai found a psychological test for TT. This test contains N problems and each option for each problem leads to another problem. And then one or more problems may leads TT to a result. For example:
      Problem 1:
        A. To 2   B. To 2   C. To 2   D. A
      Problem 2:
        A. B      B. C      C. D      D. E
    The content above means: If you choose A, B, C of problem 1, you should do problem 2 next. If you choose D of problem 1, the result is type A. If you choose A of problem 2, your result is type B. Now TT has done the test and gets a result in T steps. Can you guess which result is she?
  • 输入
  • This problem contains several problems.
    The first line of each problem is two integers N and Q. (1 <= N <= 20, 1 <= Q <= 100)
    Next follow N lines. Each line contains four options. The format is like that:
    (A, B, C, D by order).(ProblemID or ResultID)
    ProblemID is numbered from 1 to N. ResultID is signed between A to E.
    Then follow Q lines. Each line contains an integer T, means TT finished this test at step T. (1 <= T <= 1 000 000 000)
  • 输出
  • For each query of step T, you shoule output the probably results of TT by lexicographical order. If TT lied (means TT can't get a result at step T), then output 'TT loves to lie'.
  • 样例输入
  • 3 2
    A.2 B.3 C.A D.B
    A.1 B.3 C.A D.C
    A.2 B.1 C.D D.E
    2
    3
    
  • 样例输出
  • A C D E
    A B C D E
    
  • 提示
  • 来源
  • XadillaX
    
  • 操作

显示春菜