Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: Colour Sequence
Description We have a pile of cards consisting of 100 cards that are coloured on both sides. There is a finite number of colours (at most 26). In addition there are special cards called jokers. Jokers have a joker sign on both sides, which can assume any of the possible colours. We consider here a one-player card game, in which the player is challenged to derive a given colour sequence from a given row of cards, following certain rules. Before the actual beginning of the game a colour sequence These steps lead to the final sequence of colours formed by the visible side of the cards in the row. If the player has been able to turn the cards in such a way that the pre-given colour sequence Your job is to find out if the player can win, given the colour sequence Input The first line of the input file contains a single number: the number of test cases to follow. Each test case has the following format: One line describing the colour sequence *S*. This line contains a string of m (with 1 ≤ m ≤ 100) characters from the set {`'A'`,`'B'`, …,`'Z'`}, denoting the colours. Different colours correspond to different characters. For example:`"BGBG"`denotes the sequence blue, green, blue, green.Two lines, corresponding to the row of cards chosen from the pile. Each of these lines contains a string of The string in the first line corresponds to the row of colours on the visible side of the cards. The string in the second line corresponds to the row of colours on the hidden side of the cards.*k*(1 ≤ k ≤ 100) characters from the set {`'A'`,`'B'`, …,`'Z'`,`'*'`}. The character`'*'`denotes a joker, which can play the role of any of the possible colours.So for the *i*^{th}card in the row, the first line gives the colour of the side turned upwards and the second line shows the colour of the side face down. Obviously the strings on both lines have the same length. Furthermore, a`'*'`in one line (denoting a joker) always corresponds to a`'*'`in the other line at the corresponding position.
Output For every test case in the input file, the output should contain one line. This line contains Sample Input 3 RBY B*RRB G*BRY BGBG RZ*Y*PGG AB*Y*BCB BAPC BUBCDAPVDAVVDLPF VLDCUSPGLSGPPVDD Sample Output win win lose Source |

[Submit] [Go Back] [Status] [Discuss]

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di

Any problem, Please Contact Administrator