لینکهای مفید برای شرکت در مسابقه:
در طول مسابقه، میتوانید سؤالات خود را از قسمت «سؤال بپرسید» مطرح کنید.
In the dormitory, people will take turns to buy dinner or stuff for dinner. Each night one person goes out to buy and writes details of it on the “Detail Paper”. Details include name of the buyer, amount of money he/she paid and name of the people ate that night. Image below shows a Detail Paper.
At the end of each month everybody have to pay their debts, But everyone get’s so creepy when it comes to money. So they all decided to hire a team from ACM(Abdominal Control Market) of the SBU University.
you are one of the teams participating in ACM Newbies Contest so you have to help them. They only have two rules:
First line of input contains an integer indicating number of test cases. Each test case contains an integer , number of lines to follow.
Each line of test case is as following: A string name of the buyer followed by an integer cost of things bought followed by an integer , indicating how many people ate that specific night, Following N space separated strings indicating name of the people that ate that night. It’s guaranteed that C is divisible by N and Each line contains no more than 250 characters.
Each Name contains “A-Z” and “a-z” characters. Names are NOT case-sensitive and length of each name is at most 20 characters.
For each test case output “Case #X:” (quotations for clarify) which X is the number of test case.
Then print “Debtors:” (quotations for clarify) and in each line print name of debtors and their liability as following sorted by debtors name in alphabetical order: “S owes D Tomans.” (quotations for clarify)
First alphabetical character of S must be uppercase and rest of alphabetical characters must be lowercase, D is an integer number (money person S must pay).
Then print “Creditors:” (quotations for clarify) and in each line print name of creditors and their credit as following sorted by creditors name in alphabetical order: “S paid D Tomans.” (quotations for clarify)
First alphabetical character of S must be uppercase and rest of alphabetical characters must be lowercase, D is an integer number (money person S must get).
People who don’t have to pay or receive any money are neither Debtor nor Creditor, so their name should not appear in output.