The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e'. He was a member of the Oulipo group (fr. OULIPO, Ouvroir de littérature potentielle), an association of writers and mathematicians who explored the potential capabilities of language by studying known and inventing new artificial literary constraints.
A quote from the book:
Tout avait Pair normal, mais tout s'affirmait faux. Tout avait Fair normal, d'abord, puis surgissait l'inhumain, l'affolant. Il aurait voulu savoir où s'articulait l'association qui l'unissait au roman : stir son tapis, assaillant à tout instant son imagination, l'intuition d'un tabou, la vision d'un mal obscur, d'un quoi vacant, d'un non-dit : la vision, l'avision d'un oubli commandant tout, où s'abolissait la raison : tout avait l'air normal mais…
Perec would probably have scored high (or perhaps, low) in the following contest. People are asked to write, possibly even a meaningless, text in which a given "word" occurs as few times as possible. The jury is provided with a program that counts the number of occurrences of this word in the text, thus establishing the competitors' rankings. Participants often write very long meaningless texts; for example, a text consisting of 500,000 consecutive 'T's is not unusual. And they never use spaces.
We want to quickly determine how often a word (i.e., a given string) occurs in a text. More formally: given the alphabet {'A', 'B', 'C', ..., 'Z'} and two finite strings over this alphabet—a word and a text —count the number of occurrences of in . All consecutive characters of must exactly match consecutive characters of . Occurrences may overlap.
The first line contains the number of test cases. Each test case is formatted as follows:
The first line contains the word , a string over {'A', 'B', 'C', ..., 'Z'}, where 1 \leq |W| \leq 10000 ( denotes the length of ).
The second line contains the text , also a string over {'A', 'B', 'C', ..., 'Z'}, where |W| \leq |T| \leq 1000000.
For each test case, print a single number on a separate line—the number of occurrences of the word in the text .
Example 1