Max and his older brother Min had an unbreakable bond throughout their lives. However, a few years ago, Min moved to the Sombrero Galaxy, where he opened a coffee shop, El Café, and became very successful.
Following his family's passion for coffee, Max applied for a job at his brother's coffee shop. The first stage of the selection process is a simulation of a normal working day, which would be straightforward if not for the unconventional way the café serves its customers.
At El Café, there is only one type of drink, the vainilla helada, which consists of a combination of ALL (yes, all) the available ingredients in the store at that moment. Furthermore, each ingredient must be equally distributed among the ordered drinks, based on the quantity of each. Thus, when a customer places an order at El Café, they only specify the number of vainillas heladas they want, and, if possible, the employee must prepare the order. If it is not possible, the customer should be informed that the requested quantity of drinks cannot be made at that time.
For example, if the current list of ingredient quantities is $$$[24, 12, 3]$$$ and a customer orders $$$3$$$ vainillas heladas, Max should inform them that he can fulfill the order, as he can prepare three drinks, each using ingredient quantities $$$[8, 4, 1]$$$. On the other hand, if the customer had requested 2 drinks, Max would have had to inform them that it is not possible at the moment.
During the shift, new ingredients may arrive, and some of the newest ingredients may expire, forcing Max to throw them away (expiration works differently in the Sombrero Galaxy).
To increase his chances of getting the job, Max decides to call you (since he knows your programming skills) and asks you to write a program to help him train for the selection process.
The program must handle $$$3$$$ types of requests:
Given the number $$$N$$$ of different ingredients at the beginning of the shift, the quantity $$$a_i$$$ of each ingredient, and the $$$Q$$$ requests, write a program to help Max pass the test.
The first line consists of two integers $$$N$$$ and $$$Q$$$ $$$(1 \le N, Q \le 10^{5})$$$, representing the number of ingredients at the start of the shift and the number of requests, respectively.
The second line contains $$$N$$$ integers $$$a_1, a_2, \cdots, a_N$$$ $$$(1 \le a_i \le 10^9)$$$, where $$$a_i$$$ represents the quantity of the $$$i$$$-th ingredient in order from oldest to newest.
Then, $$$Q$$$ lines follow, each representing a request.
For each request of type $$$3$$$, print a single line. If it is possible to fulfill the customer's order, print "SIM", otherwise print "NAO".
5 512 12 6 4 22 33 41 61 33 2
SIM NAO
3 320 20 43 51 103 2
NAO SIM