HELLOKIT - Hello Kitty

Kitty sends a kind of original email messages to her friend Garf. To write a message, she chooses a word W and a number n and replicates W n times horizontally. Then she repeats this string in the next line, but rotating the characters once to the left. And she repeats this 'rotate-and-output' process until the word W appears displayed as the first column of the rectangular pattern that she produces. As an example, when she chooses the word Hello and the number 3, she gets the pattern:


HelloHelloHello
elloHelloHelloH
lloHelloHelloHe
loHelloHelloHel
oHelloHelloHell

Kitty has been sending such emails during the last three years. Recently, Garf told her that perhaps her work may be automatized with a software to produce Kitty's patterns. Could you help her?

Input

The input contains several test cases, each one of them in a separate line. Each test case has a word and a positive integer that should generate the corresponding rectangular pattern. The word is a string of alphabetic characters (a..z). The number is less than 10.

A line whose contents is a single period character means the end of the input (this last line is not to be processed).

Output

Output texts for each input case are presented in the same order that input is read. For each test case the answer must be a left aligned Kitty pattern corresponding to the input.

Example

Input:
Love 1
Kitty 2
.

Output:
Love
oveL
veLo
eLov
KittyKitty
ittyKittyK
ttyKittyKi
tyKittyKit
yKittyKitt

Added by:Daniel Gómez Didier
Date:2009-10-31
Time limit:0.209s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 NODEJS OBJC PERL6 SQLITE VB.NET

hide comments
2012-02-06 08:01:58 saket diwakar
take string limit as 500..
it caused me 20 runtime errors....
what the hell....
2012-01-08 18:15:29 guliashvili
WTF? nothing is bounded.is it problem or just a fiction story? :|
2011-12-17 10:03:04 张翼德
what the #uck.. string length costed me 3 SIGSEGV runtime errors..

Last edit: 2011-12-17 10:03:51
2011-12-09 15:59:06 R. Sibi
I'm getting a SIGSEGV error. What could be the problem ???

http://www.spoj.pl/forum/viewtopic.php?f=3&t=10196
2011-10-17 12:34:17 orochimaru
> displayed as the rst column of the rectangular
pattern that she produces.


What does 'rst' column mean ? Is it supposed to be 'first' ?
2011-10-07 16:53:15 Loki
The number must not be "less" than 10.
2011-08-11 17:09:28 Jagat Sastry P
Problem title should be changed to NyanCat and there should be only one possible word - Nyan
2011-06-23 19:05:38 Matej Badin
@Rhonal Chirinos [UCLA-VE] The end of file is "." , not "-.-" This gave me WA
2011-05-28 19:46:46 Rhonal Chirinos [UCLA-VE]

-.-!
2011-05-23 13:58:49 albertg
I dont think so, ^::^. For xyx 2 output is
xyxxyx
yxxyxx
xxyxxy
xyxxyx
yxxyxx
xxyxxy
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.