Goods Market

No attempts yetTime limit1sMemory limit256 MB

Problem

A market called Goods Market has just opened. It starts with NN shops, and new shops keep moving in. The market is large enough to hold any number of shops.

The owner can raise the rent. One raise adds KK baht to the rent of every shop that is in the market at that moment. A shop that goes through two raises pays 2K2K baht more than its starting rent. A shop that moves in after the first raise and goes through only the second one pays KK baht more. A shop is affected only by the raises that happen after it moves in.

When there are too many tenants, the owner evicts one shop with the cheapest rent. If several shops share the cheapest rent, the owner evicts one of them, and the sum of the remaining rents is the same either way. The owner decides when to evict.

The market goes through MM operations of three types.

  1. A new shop moves in at a rent of PP baht.
  2. The rent of every shop in the market goes up by KK baht.
  3. The owner evicts one shop with the cheapest rent. If the market has no shop, nothing happens.

Find the number of shops left after all operations and the sum of their rents.

Input

The first line has the number of questions TT. (1T201 \le T \le 20)

The first line of each question has three integers NN, MM, KK. (1N,M100,0001 \le N, M \le 100{,}000, 1K1001 \le K \le 100)

The next line has NN integers XiX_i, the starting rent of shop ii. (1Xi10,000,0001 \le X_i \le 10{,}000{,}000)

Each of the following MM lines has the operation type AA. When AA is 1, the same line also has an integer PP. (1P10,000,0001 \le P \le 10{,}000{,}000) When AA is 2 or 3, the line has that one integer only.

Output

For each question, print the number of shops left after all operations and the sum of their rents on one line, separated by a space.