HELLOKIT - Hello Kitty

no tags 

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

hide comments
arbit: 2011-05-16 05:34:12

what is the end of input correctly ? I could not understand someone please explain with one or more examples

Last edit: 2011-05-19 03:35:27
Aamir Khan: 2011-03-29 16:43:15

take upper limit of text string to safe side of 50 character...it gave me AC :)

^::^: 2011-03-03 16:18:13

@;sandeep-
Output for xyx 2 is
xyxxyx
yxxyxx
xxyxxy

M. Zuhriyan Sauqi: 2011-02-21 09:42:04

I got RE SISGEV, what does its mean?

avatar: 2011-01-08 13:54:19

What is the upper limit on the length of input text?

Benediktus Anindito: 2010-10-13 10:48:07

hope this could be solved in python :D

Chandra Sekar: 2010-07-10 08:30:58

@Tornike Mandzulashvili
Y dont u try the substring function in C++. It is cakewalk if u do!

Tornike Mandzulashvili: 2010-07-07 16:20:48

it is writing time limit exceeded but my programs speed is n*n*k !

Last edit: 2010-09-07 08:38:10
Abhisek Banerjee: 2010-05-30 16:30:10

getting wa...cant understand why..but my prog prints the output correctly..

Rishi Kumar: 2010-04-26 05:17:26

givs me WA too...
but works perfectly on ma system!


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