Task: Program Execution
Input (English): 3, 3, ['Q', '6701', '3947', 'r', '9711', '4971']
Output (English): 3947