#C8615. Rotate String
Rotate String
Rotate String
You are given a string s and an integer k. Your task is to rotate the string to the right by k positions. This means that the last k characters of the string will become the first k characters of the resulting string, and the remaining characters will follow.
More formally, let the length of the string be \(n\). The rotated string is constructed as follows:
[ \text{rotated}(s, k) = s[n-k \bmod n \ldots n-1] + s[0 \ldots n-k \bmod n -1] ]
Note: When \(k \ge n\), it should be treated as \(k \bmod n\).
inputFormat
The input is read from stdin in the following format:
T s1 k1 s2 k2 ... sT kT
where T
is the number of test cases, and for each test case, s
is the string and k
is the integer representing the number of positions to rotate the string.
outputFormat
For each test case, print the rotated string on a separate line to stdout.
## sample2
hello 2
world 3
lohel
rldwo
</p>