A deck holds 100 cards that are coloured on both sides. There are at most 26 different colours. The deck also holds special cards called jokers. A joker carries a joker sign on both sides and can take any of the possible colours. The game here is a one player game in which the player has to build a given colour sequence out of a given row of cards.
Before the game starts, a colour sequence S of length at most 100 is fixed. S contains no joker. A number of cards are then taken from the deck and laid out in a row, and the faces turned upwards form a row of colours. The player goes through the row and decides for each card whether to turn it over. Once a card is turned over, only the colour on the other side is visible. Jokers may sit anywhere in the row.
After every decision, the visible faces form the final row of colours. The player wins if S is contained in that final row from left to right, and loses if it is not. Cards in the row may be skipped while matching S, as long as the relative order of the colours is preserved. A joker can take any colour. For example, the colour sequence (red, blue, yellow) is contained in (green, joker, blue, red, yellow), and (blue, green, blue, green) is contained in (red, blue, joker, yellow, joker, blue, green, green).
You are given the colour sequence S and the row of cards taken from the deck, so the colours that are face up are known and so are the colours on the other side of the same cards. Decide whether the player can win.
The first line contains the number of test cases. Each test case has the following format.
BGBG denotes the sequence blue, green, blue, green.*}. The character * denotes a joker, which can play the role of any of the possible colours.The first of the two lines gives the colours on the visible side of the cards, and the second gives the colours on the hidden side. So for the ith card in the row, character i of the first line is the side turned upwards and character i of the second line is the side turned downwards. Both lines always have the same length, and a * in one line always has a * at the same position in the other line.
For every test case, print one line. Print win if the player can turn the right cards over so that the colour sequence S is contained in the row, and lose if this is not possible.