SP14975 UOFTAF - Foxic Expressions

Description

Let's talk about some definitions, shall we? An uppercase letter is a character between "A'' and "Z'', inclusive. You knew that. A string is a sequence of characters. You probably knew that. A Foxic letter is a superior uppercase letter - namely, one of "F", "O", or "X". You probably didn't know that. A Foxic string is a superior string, consisting only of Foxic letters. You didn't know that. Finally, a Foxic expression is a special string, with each of its characters being either a Foxic letter, or an "n" immediately following a Foxic letter. A Foxic expression can be translated into a Foxic string by a three-step process. First, up to one character can be added, removed, or modified, provided that the resulting string is still a valid Foxic expression. Next, every Foxic letter immediately preceding an "n" is replaced by zero or more occurrences of that same letter. Finally, each "n" is removed. You most certainly did not know that. There are $ T $ ( $ 1 \leq T \leq 100 $ ) scenarios to consider, as described above. In each scenario, given a Foxic string $ S $ of length $ N $ ( $ 1 \leq N \leq 100 $ ) and a Foxic expression $ E $ of length $ M $ ( $ 1 \leq M \leq 100 $ ), you'd like to determine whether or not $ E $ can be translated into $ S $ .

Input Format

Line 1: 1 integer, $ T $ For each scenario: Line 1: 1 integer, $ N $ Line 2: 1 string, $ S $ Line 3: 1 integer, $ M $ Line 4: 1 string, $ E $

Output Format

For each scenario: The string "Yes" (without quotes) if $ E $ can be translated into $ S $ , or "No" otherwise.