Binary Strings
시간 제한2초메모리 제한2048 MB
주어진 s 문자열 두 개를 부분 문자열로 포함하면서 어떤 t 문자열도 부분 문자열로 포함하지 않는 이진 문자열이 존재하는지 판정한다.
문제
Given non-empty binary strings and another non-empty binary strings , determine if there exists such a binary string that:
- There exist and such that , and both strings and appear in as substrings.
- For all such that , string does not appear in as a substring.
입력
The first line contains one integer () denoting the number of test cases. For each test case:
The first line contains two integers and (, ).
The following lines contain non-empty binary strings , one per line.
The following lines contain non-empty binary strings , one per line.
For the total sums over all test cases, it is guaranteed and that .
출력
For each test case, output a line containing a single string: "Yes" (without quotes) if such a binary string exists, or "No" (without quotes) if not.
힌트
For the first case, one possible string is "0100", where 100 and 010 appear in it, but 1001 and 000 don't appear.