SPOJ 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