Your program’s output has to match the expected output exactly. Sometimes, you might get away with a little difference in whitespace, but sometimes you won’t, so it’s always better to err on the side of caution and match the expected output as closely as you can.
Your output differs from the expected output because your output contains these:
enter the number of test cases
Enter the digit at index x
A second point is that the input doesn’t actually contain the number of test cases. You need to read all numbers until you detect the 42.
A third point is that it’s generally not a good idea to make assumptions about the test data. Try not to rely on something that isn’t stated in the problem statement. For example, it doesn’t say there won’t be more than 100 numbers, so it’s bad practice to make that assumption.