Task: Program Execution
Input (English): N, J, 6507, E, 1889, S
Output (English): 8396