King and Magician
There is a magician who can transform Iron objects to Gold replicas and vice versa. The King decides to experiment the claims of the magician by putting forward an sequence of such objects. A Gold object is represented by a + and an iron object is represented by a -
The condition of play put forward by the king is as follows:
1. If the first object of the sequence is Gold then the last object must change its type (gold should change to iron and vice versa)
2. The leftmost object in the sequence is removed, and is added into the sequence from the right side after undergoing transformation(gold should change to iron and vice versa).
After applying these two protocols on the sequence, the King counts up by 1. The King wants to know, the state of his objects after a given number of counts. At count 0, sequence is in its original state
First line will consist of an integer h which denotes the no. of experiments conducted by King.
Next line consists of m and n where m represents the length of the sequence and n represents the no. of queries asked by the king.
Next line consists a string of length m composed of '+' and '-' where '+' represents the gold and '-' represents the iron. This sequence will be the initial state (count 0).
Then, there will be n lines with an integer n(i), representing the count no. at which king wants to know the state of the sequence.
For each experiment one line containing "Experiment #j" , being j the jth experiment magician is conducting.
Then, n strings in each new line, representing the sequence at that time.
1 ≤ h ≤ 15
1 ≤ m ≤ 14
1 ≤ n ≤1000
0 ≤ n(i) ≤ 109
Input: 1 4 6 +--+ 0 2 3 5 7 10 Output: Experiment #1: +--+ ---+ --++ ++++ +-+- +---
|Time Limit:||1 - 2 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions