Binary Strings

시간 제한2초메모리 제한2048 MB

문제

Given $n$ non-empty binary strings $s_1, s_2, \ldots, s_n$ and another $m$ non-empty binary strings $t_1, t_2, \ldots, t_m$, determine if there exists such a binary string $S$ that:

  • There exist $i$ and $j$ such that $1 \le i < j \le n$, and both strings $s_i$ and $s_j$ appear in $S$ as substrings.
  • For all $i$ such that $1 \le i \le m$, string $t_i$ does not appear in $S$ as a substring.

입력

The first line contains one integer $T$ ($1\le T \le 10^5$) denoting the number of test cases. For each test case:

The first line contains two integers $n$ and $m$ ($2 \le n \le 10^5$, $1 \le m \le 10^5$).

The following $n$ lines contain non-empty binary strings $s_1, s_2, \ldots, s_n$, one per line.

The following $m$ lines contain non-empty binary strings $t_1, t_2, \ldots, t_m$, one per line.

For the total sums over all test cases, it is guaranteed $\sum n + \sum m \le 10^5$ and that $\sum |s_i| + \sum |t_i| \le 10^6$.

출력

For each test case, output a line containing a single string: "Yes" (without quotes) if such a binary string $S$ exists, or "No" (without quotes) if not.

힌트

For the first case, one possible string is "0100", where $s_1 = $100 and $s_3 = $010 appear in it, but $t_1 = $1001 and $t_2 = $000 don't appear.