لینکهای مفید برای شرکت در مسابقه:
در طول مسابقه، میتوانید سؤالات خود را از قسمت «سؤال بپرسید» مطرح کنید.
Colonelmo and CaptainH1 were hanging out at Cluna when they noticed something strange. Cluna allows the customers to pay by credit card in a super secure way: The guy at the counter simply asks about your card's password. And if that isn't enough, he will shout it out as loud as possible after he hears it from you.
We know that there are people who are going to Cluna today, and the -th person's credit card password is equal to a digit number (possibly containing leading zeroes). We know that the people pay (and therefore tell their password) when they are about to leave the shop. We also have the customers' entrance/exit times. Since the guy at the counter repeats the password in a really loud voice, everybody present in the shop at that particular moment will hear it. A customer can memorize a password if and only if she is present at the shop while the cashier is shouting it and the password which is being told is similar to his own password. Two passwords are said to be similar if and only if one is a rearrangement of the digits of the other one ( is similar to say, and etc.).
As always, CaptainH1 is quite concerned about security matters. She asks Colonel, how many passwords that belong to other people are known to each of the customers at the end? Colonel is too busy browsing 9gag and knows that CaptainH1 won't give him his kindersurprise if he doesn't answer in time. Can you help him?
The first line of input contains an integer and in the next line space separated Integers .
Next line contains an integer indicating total number of entrances/exists that have happened ordered by the time of happening.
Each of following lines contains an integer denoting person will enter the shop if she is not in the shop, or otherwise she will pay and leave the shop.
Print space separated numbers each denoting the number of other people whose password is known to -th person.