Iris runs a worldwide espionage network, and its true nature stays hidden. Its members range from ordinary students to leading figures in academia, finance, and politics, and they pass the organization's codes to one another hidden inside ordinary-looking text: a salesperson's thank-you note, a news headline, an entrance-exam paper, and so on.
A member named Baeksan has been told how to pull a password out of such text. Given a word and a text, the password is how many times the word occurs in the text together with where each occurrence ends. The first number of the password is the number of occurrences; the numbers that follow are the positions of those occurrences.
What counts as an occurrence
How it is decided (greedy)
Scan the text once from left to right. Several copies of the word may be under construction at the same time. For each character:
c of the word and there is an unfinished copy that has already been filled up to the letter before c (a copy waiting for c), advance one such copy with this character. If there is no such waiting copy, discard this character.Because no letter appears twice in the word (ignoring case), each character of the text matches at most one letter of the word. Under this rule, whenever several places could serve as the last character, the earliest one is always taken as that occurrence's position.
Input is read from standard input. The first line contains the number of test cases T (1≤T≤20).
Each test case consists of two lines.
The word has length at most 10, and the text has length at most 200,000. A single word may occur up to 40,000 times in the text. Ignoring case, no character appears more than once within a word.
For each test case, print one line to standard output. The first integer on the line is the number of occurrences of the word; the integers that follow are the positions of the occurrences (the place where the word's last character sits in each occurrence). Positions count the first character of the text as 1.
If there are three or more occurrences, print only the first three positions, so the line then holds four integers. If there are no occurrences, print only 0 on that line.