P3538 [POI 2012] OKR-A Horrible Poem

题目描述

Bytie boy has to learn a fragment of a certain poem by heart. The poem, following the best lines of modern art, is a long string consisting of lowercase English alphabet letters only. Obviously, it sounds horrible, but that is the least of Bytie's worries. First and foremost, he completely forgot which fragment is he supposed to learn. And they all look quite difficult to memorize... There is hope, however: some parts of the poem exhibit certain regularity. In particular, every now and then a fragment, say ![](http://main.edu.pl/images/OI19/okr-en-tex.1.png), is but a multiple repetition of another fragment, say ![](http://main.edu.pl/images/OI19/okr-en-tex.2.png) (in other words, ![](http://main.edu.pl/images/OI19/okr-en-tex.3.png), i.e., ![](http://main.edu.pl/images/OI19/okr-en-tex.4.png), where ![](http://main.edu.pl/images/OI19/okr-en-tex.5.png) is an integer). In such case we say that ![](http://main.edu.pl/images/OI19/okr-en-tex.6.png) is a full period of ![](http://main.edu.pl/images/OI19/okr-en-tex.7.png) (in particular, every string is its own full period). If a given fragment has a short full period, Bytie's task will be easy. The question remains... which fragment was that? Make a gift for Bytie - write a program that will read the whole poem as well as a list of fragments that Bytie suspects might be the one he is supposed to memorize, and for each of them determines its shortest full period.

输入格式

输出格式