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
dewa251202: 2018-10-06 02:20:22

Yay ac using string

romiromi: 2017-01-31 03:20:14

easy :')

gustavoaca1997: 2016-06-01 07:26:35

YES! Time: 0.00, Memory Used: 3.3M

shivam_15: 2015-10-31 17:54:31

@(Tjandra Satria Gunawan)(曾毅昆): Please can you tell how the length of the word is 26

shivam_15: 2015-10-31 17:51:43

Please can you tell how the length of the word is 26

shivam_15: 2015-10-31 17:51:22

@UnrealNinja: Please can you tell how the length of the word is 26

karthik1997: 2015-07-14 13:24:36

ac in 1 go 0..s
easy one
and if n==0 use continue statement bur dont go below the loop :)

Saksham : 2014-12-20 21:20:13

GOt Ac in first attempt

Govind Lahoti: 2014-09-15 20:13:32

nice one :)

pika_pika: 2013-07-07 14:12:39

Easy, AC in 1st attempt with java


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