After defeating the Voldemort, Harry is enjoying his senior year in Hogwarts with his friends. They decide to make a graduation trip, using their newest magical broom. In the journey, Harry is trapped in a Kingdom named Binary Kingdom, maybe because the smart but isolated people still have no idea of the great reputation of this young wizard. Loving numbers and binary very much, the subjects of Binary Kingdom claim only Harry solve the problem can he leave there.
The problem begins with an empty number multi-set, with six kinds of operation:
1. INS M: insert M into the set
2. DEL M: delete all numbers equal to M if any one exists; otherwise report “Del error”
3. ADD M: increase the value of every number by M
4. SUB M: decrease the value of every number by M if after decreasing no number will be less than zero; otherwise report “Sub error”
5. QNUM M: query how many numbers equal to M in the set
6. QBIT M: query how many numbers whose M-th bit is 1 in its binary, M is counting from lower to higher, beginning with 0
Though our brave Harry Potter can proficient in many fields, he is not good at math, now, it’s your time.