Hello everyone, I came up with this problem and I can't figure a solution out. I don't know if it has appeared before.

You are given a matrix of size *n* × *m*. Answer two types of queries:

- 1 *k* *i*_{1} *i*_{2} ... *i*_{k}: Set the *active* set to {*i*_{1}, *i*_{2}, ..., *i*_{k}}.

- 2 *x*: What is the value of *a*_{i1, x} + *a*_{i2, x} + ... + *a*_{ik, x}, where *i*_{1}, *i*_{2}, ..., *i*_{k} are the current elements in the *active* set?

There are less than *n* queries of type 1, and less than *m* queries of type 2 between a pair of queries of type 1.

1 ≤ *n*, *m* ≤ 2000, however solutions with any reasonable complexity are welcome.

Also, if a query of type 1 appears for the *i*-th time, 1 ≤ *k* ≤ *i*.