SPOJ BEADS

11391 - EASY MATH

 * http://www.spoj.pl/problems/BEADS/

Summary
Find the lexicographically smallest cyclic string of length l.

Implementations
Concatenate the string with itself. form substring of length l from 0th position to l-1 th position. print the least.

Input
4 helloworld amandamanda dontcallmebfu aaabaaa

Output
10 11 6 5