Row 2
A vertically positioned rectangular paper strip, fixed at the lower end, is folded in the following manner:
In the first step, the strip is folded in half so that the upper half lies on the lower half, either in front (P-fold) or behind (Z-fold).
For the next n-1 steps, the same folding action is repeated on the strip folded in the previous step, treating it as a single unit.
After completing the folding sequence, the strip is unfolded back to its original state. It retains creases from the folds, with some edges protruding towards the viewer (K-edges) and others away from the viewer (O-edges). The edges are numbered sequentially from top to bottom, ranging from 1 to 2^n-1.
Objective: Write a program that, given a sequence of uppercase letters "P" and "Z" representing the fold types, and a list of edge numbers, determines the type of these edges after the folding and unfolding process.
Input
The input consists of three parts: the first line contains the integer n, representing the number of times the strip is folded (with n not exceeding 60). The second line contains a sequence of n uppercase letters "P" and "Z". The third line starts with the integer k, indicating the number of edges to be considered (not exceeding 10), followed by the specific edge numbers (ranging from 1 to 2^n-1).
Output
The output should be a single line containing k characters (either "K" or "O"), representing the types of the specified edges.