#K61397. Rotate String by K Positions

    ID: 31300 Type: Default 1000ms 256MiB

Rotate String by K Positions

Rotate String by K Positions

You are given a string \(S\) and an integer \(K\). Your task is to rotate the string to the right by \(K\) positions. In other words, take the last \(K \bmod |S|\) characters of \(S\) and move them to the beginning of the string.

For example, if \(S = \texttt{hello}\) and \(K = 2\), then the rotated string will be \(\texttt{lohel}\). Similarly, if \(S = \texttt{abcde}\) and \(K = 5\), the rotated string remains \(\texttt{abcde}\) because \(5\) is a multiple of \(|S|\). Use standard input and output in your solution.

inputFormat

The first line of input contains an integer \(T\) which represents the number of test cases. Each of the following \(T\) lines contains a test case with a string \(S\) and an integer \(K\) separated by space. You can assume that \(S\) does not contain spaces.

outputFormat

For each test case, output the rotated string on a new line.

## sample
2
hello 2
abcde 5
lohel

abcde

</p>