QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 512 MB 總分: 100

#2867. Text Correction

统计

While developing a data obfuscation algorithm, Little Q accidentally obfuscated some important documents. Fortunately, correcting these documents is not difficult for him. With his keen observation, he successfully corrected them by eye.

To prevent this from happening again, Little Q wants to develop a text correction tool. His goal is to split a text string $T$ into three consecutive segments, where each segment must be non-empty, and then concatenate these three segments in a certain order from left to right to restore it to the original text string $S$.

After a large amount of manual correction work, Little Q needs a break, so he has handed this task over to you. Please write a program to determine if it is possible to restore the string and, if so, provide a valid restoration scheme.

Input

The first line contains a positive integer $Case$, representing the number of correction tasks.

Each of the following $Case$ sections represents a correction task. The first line of each section contains two positive integers $n$ and $m$, representing the length of the text string and the size of the character set, respectively.

The second line of each section contains $n$ positive integers $S_1, S_2, \dots, S_n$, representing the string $S$.

The third line of each section contains $n$ positive integers $T_1, T_2, \dots, T_n$, representing the string $T$.

Output

For each correction task, if there is no solution, output a single line containing "NO". Otherwise, output "YES" on the first line, followed by three lines, each containing two positive integers $l_i, r_i$, representing the three substrings of $T$ in the order they are concatenated.

If there are multiple valid restoration schemes, you may output any one of them.

Examples

Input 1

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

Output 1

YES
5 5
1 3
4 4
NO
YES
2 2
1 1
3 5

Note

For 100% of the data, $3 \le n \le 1000000$, $1 \le S_i, T_i \le m \le 1000000$.

Test Case Number $n, m$ $Case$ $\sum n, \sum m$
1, 2 $\le 6$ $\le 50000$ $\le 300000$
3, 4, 5, 6 $\le 2000$ $\le 10$ $\le 20000$
7, 8, 9, 10, 11, 12 $\le 200000$ $\le 30$ $\le 200000$
13, 14, 15, 16, 17, 18, 19, 20 $\le 1000000$ $\le 30$ $\le 1000000$

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.