#P8270. Coded Information Exchange
Coded Information Exchange
Coded Information Exchange
The cows are trying out a new method of exchanging encoded information. They mix extraneous letters into the transmission to make decoding harder. In this problem, you are given two strings (s) and (t), each of length at most (10^5) and consisting only of the lowercase letters 'a' to 'r'. You will also be given (Q) queries ((1 \le Q \le 10^5)).
In each query, you are provided with a subset of the letters from 'a' to 'r'. For each query, form the filtered strings (s') and (t') by keeping only the characters in (s) and (t) that belong to the given subset (preserving their original order). Your task is to determine if (s' = t').
inputFormat
The first line contains the string (s).
The second line contains the string (t).
The third line contains an integer (Q), the number of queries.
Each of the next (Q) lines contains a non-empty string representing a subset of allowed letters (each character is between 'a' and 'r').
outputFormat
For each query, output a single line containing either YES
if the filtered versions of (s) and (t) are equal, or NO
otherwise.
sample
abcde
abfde
3
abd
b
ef
YES
YES
NO
</p>