



The first line of input contains an integer 'T' which denotes the number of test cases or queries to be run.
Then the test cases follow:
The first line of each test case contains the string 'str'.
The second and last line of each test case contains an integer 'D', representing the number of units by which the string is to be rotated left or right.
For each test case, print the left and right rotations of the string separated by a single space.
Output for every test case will be printed in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1. leftRotate(): This function should return the string after left rotation.
2. rightRotate(): This function should return the string after right rotation.
1 <= T <= 10
1 <= |str| <= 10^5
1 <= D <= 10^5
Where |str| denotes the length of the string str.
Time Limit: 1 sec
The idea is to use an additional string to store the copies of required substrings. So we will Make initialize an empty string named ‘ANS’.
Explanation with an example:
Let the given string = ”abcdef” , D = 2.
Initialize ‘ANS’ = ””, for left rotation:
For right rotation again initialize ans to empty:
Let the given string is ”abcdef” and D = 2.