Task: Program Execution
Input (English): P, Q, 1685, 5509, J, G, T, 9433, g, h, 1705, w, t, T, 133
Output (English): 18465