#P3785. [SDOI2017] 文本校正
[SDOI2017] 文本校正
Description
While developing a data obfuscation algorithm, Xiao Q accidentally obfuscated some important documents. Fortunately, correcting these documents is not difficult for him. With keen observation, he managed to correct them by eye.
To prevent this from happening again, Xiao Q wants to develop a text correction tool. His goal is to split a string into three consecutive segments, each of which must be non-empty, then concatenate these 3 segments from left to right in some order to restore the original string .
After a lot of manual correction, Xiao Q needs a break, so he assigns this task to you. Please write a program to determine whether restoration is possible, and if so, output a valid restoration plan.
Input Format
The first line contains a positive integer , the number of correction tasks.
Then follow parts, each describing one task. The first line of each part contains two positive integers , , denoting the length of the string and the size of the character set, respectively.
The second line of each part contains positive integers , representing the string .
The third line of each part contains positive integers , representing the string .
Output Format
For each task, if there is no solution, output a single line "NO" (without quotes). Otherwise, output "YES" (without quotes) on the first line, and then output three lines, each containing two positive integers , , representing the 3 substrings of in the concatenation order.
If multiple restoration plans exist, output any one of them.
3
5 3
2 1 1 1 1
1 1 1 1 2
5 5
5 2 3 3 4
2 5 3 4 3
5 5
4 5 2 1 4
5 4 2 1 4
YES
5 5
1 3
4 4
NO
YES
2 2
1 1
3 5
Hint
Constraints: For of the testdata, , .

spj by @Wen_kr.
Translated by ChatGPT 5
京公网安备 11011102002149号