Consider a string A = "12345". An infinite string s is built by performing infinite steps on A recursively. In ith step, A is concatenated with ‘$’ i times followed by reverse of A.
A=A|$...$|reverse(A), where | denotes concatenation.
First line contains an integer Q, the number of queries. Q line follows. Each line contains an integer POS i.e. the position for query.
For each query print the character in the infinite string at position POS in separate lines.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.