#C10093. Common Substring Existence

    ID: 39260 Type: Default 1000ms 256MiB

Common Substring Existence

Common Substring Existence

Given two strings s1 and s2 and an integer k, determine if there exists a substring (a contiguous sequence of characters) that is common to both s1 and s2 with length at least k.

For each test case, output YES if such a common substring exists; otherwise, output NO.

Input is provided through stdin and the result should be printed to stdout.

inputFormat

The first line contains an integer T indicating the number of test cases. Each test case consists of three lines:

  • The first line contains an integer k.
  • The second line contains the string s1.
  • The third line contains the string s2.

outputFormat

For each test case, print a single line containing YES if there is at least one common substring of length k between s1 and s2, otherwise print NO.

## sample
2
2
abcde
cdefg
3
abcdef
ghijkl
YES

NO

</p>