Magic Cards (Hard)

아직 제출이 없습니다시간 제한10초메모리 제한1024 MB

문제

Pak Dengklek will play a magic trick. Pak Dengklek's assistant, Pak Ganesh, has NN cards numbered from 11 to NN. A spectator is invited to the stage to choose KK distinct cards out of them and give them to Pak Ganesh. Pak Ganesh sees the card, then discards one of the KK cards, then leaves the remaining K1K - 1 cards in some order on the table. Pak Dengklek then looks at the K1K - 1 cards on the table and must be able to determine the card discarded by Pak Ganesh.

Obviously, Pak Dengklek and Pak Ganesh must not communicate right after the trick is started, but they can determine their strategy before the trick is started. You must help them by designing their strategy. This time, Pak Dengklek and Pak Ganesh will play this trick QQ times with the same value of NN and KK.

제한

  • 2K82 ≤ K ≤ 8
  • KNK ≤ N
  • Strategy for magician and assistant exists for given NN and KK
  • 1Q50,0001 ≤ Q ≤ 50\\,000

For each call to choose_cards:

  • 1cards\[i]N1 ≤ cards\[i] ≤ N (for each ii such that 0iK10 ≤ i ≤ K - 1).
  • All the elements of cards are distinct.

For each call to find_discarded_card:

  • All the inputs given are the same as all QQ return values of choose_cards in random order.