string puzzle

3.3

3 votes
Problem

rishi loves to solve string puzzles. His friend kartheek gave him a task on string. which comprises of a string that has to be manipulated accordingly to the query of kartheek. for every query there will be the starting and ending index of the string and rishi has to generate all non repeating arrangements of the string in between the specified indices.

INPUT : first line consists of a string S. Next line consists of an integer representing no. of queries Q. Next q lines consists of starting and ending indices S and E respectively.

OUTPUT : Output should consists of all arrangements of string for all queries. After completion of every query leave one line and print output of next query.

Sample Input
abcd
2
1 3
2 3
Sample Output
abcd
abdc
acbd
acdb
adcb
adbc

abcd
abdc
Time Limit: 5
Memory Limit: 256
Source Limit:
Contributers:
Editor Image

?