Task: Program Execution
Input (English): M, Q, q, 3635, 4707, 6961, D
Output (English): 15303