The problem that you are solving includes a section named “Input Format”
If you read that properly you can understand what’s wrong with your code.
I specifies that the first line contains an integer t, which depicts the number of test cases, and the following t lines contain two integers.
You need to modify your code as follows:
t = int(input())
for i in range(t):
input_str = input().split() # This makes the input_str a list which contains two elements, X and Y
chef = int(input_str[0]) # The first integer is for chef
chefina = int(input_str[1]) # The Second integer is for chefina
# Add the rest of the logic inside the for loop.
If you want to simplify, the process of taking input, you can also use the following code.
for _ in range(int(input)):
chef, chefina = map(int, input().split())
# Rest of your code