There are \(T\) labs totally, and each lab contains \(N\) problems. No matter for which lab, the \(i\)-th problem always has a difficulty value of \(d_i\) (so working on this problem costs \(d_i\) energy). Since the easier problems are always placed ahead of the more difficult ones, we have \(d_i\leq d_{i+1}\) for any \(1\leq i<n\).
CC wants to show off her skills of writing codes to her classmates, so in each lab she will only choose one problem to solve. Yeah, she does not care about the scores and GPA! In detail, she will choose the most difficult problem which have a difficulty value less than or equal to her current energy value. If it happens that there is a problem with exactly the same difficulty value as her current energy value, she will happily AC the problem and shout "Accept". Otherwise, she will tell you how many energy left (which is the current energy value minus the difficulty of the problem she finishes). It's guaranteed that her current energy value can afford to do the easiest problem.
However, CC may have different energy values in different labs. So she wants to know what will happen in each lab.