손님이 도착하는 시간을 입력 받는데 정렬이 되어 있지 않는 경우도 있으므로 정렬을 해줍니다.
손님의 도착 시간들 중에서 가장 큰 시간까지 반복을 합니다.
손님은 0초에도 도착할 수 있으므로 0초가 아니고 시간 % M이 0 일 때 붕어빵을 K 만큼 증가시킵니다.
만약 현재 시간이 도착시간에서 가장 앞에 있는 시간과 같아 졌을때,
중간에 멈추지 않고 반복이 종료되었다면 Possible을 출력합니다.
T = int(input())
for tc in range(1, T+1):
N, M, K = map(int, input().split())
customer = list(map(int, input().split()))
customer.sort()
bread = 0
flag = True
max_time = max(customer)
for i in range(max_time+1):
if i%M==0 and i!=0:
bread += K
if i==customer[0]:
if bread == 0:
print(f'#{tc} Impossible')
flag = False
break
else:
customer.pop(0)
bread -= 1
if flag:
print(f'#{tc} Possible')