2015
04-14

# Harry Potter and the Present

Hogwarts is welcoming the new term! After Voldemort and the Death Eater were wiped out by Harry Potter and his friends, Harry becomes the glory of the Wizarding World, magician treat him as model, hero, king… and much more than that. So on the ceremony held to signal the beginning of a new school semester, they decide to invite Harry Potter and his three friends: Ginny, Ron and Hermione.
Back to their Alma Mater, Harry and his three friends find a store to purchase some present. They can use at most M units of money, what’s more, they don’t have enough energy to take the presents to Hogwarts if their total weight is exceeding W or the total number is exceeding S. In the store, there are N kinds of present, each of them has price Pi, weight Wi, and value Vi, and as it’s a magical world, any present’s amount is infinite and can be purchased for many times.
Unfortunately, all of them have different idea to buy the gifts. Ginny wants the total number to be the largest, while Ron thinks the more money they cost, the more sincerity there will be shown, Harry wonders the biggest weight they can take because he always likes to challenge himself, Hermione, of course, is already beginning to calculating the biggest value.
Here you see, your task is very simple, calculating the four numbers.

The first line contains a single integer T, indicating the number of test cases.
Each test case begins with four integers N, S, W, M. Then N lines following, each line contains three integers Pi, Wi, Vi, describing a present.

Technical Specification

1. 1 <= T <= 100
2. 1 <= N <= 1 000
3. 1 <= S <= 1 000 000 000
4. 0 <= Wi, Pi, W, M <= 1 000
5. 0 <= W*M <= 1 000
6. 0 <= Vi <= 1 000 000

The first line contains a single integer T, indicating the number of test cases.
Each test case begins with four integers N, S, W, M. Then N lines following, each line contains three integers Pi, Wi, Vi, describing a present.

Technical Specification

1. 1 <= T <= 100
2. 1 <= N <= 1 000
3. 1 <= S <= 1 000 000 000
4. 0 <= Wi, Pi, W, M <= 1 000
5. 0 <= W*M <= 1 000
6. 0 <= Vi <= 1 000 000

2
2 2 3 4
1 1 2
1 2 3
2 3 3 4
1 1 2
1 2 3

Case 1: 2 2 3 5
Case 2: 3 3 3 6

1. 老大，俺 想问一哈，咱这里有木有CAJ转WORD的转换器啊？俺从知网下载的文件都是CAJ格式的，咱这里只看到了PDF的转换器，老大帮帮忙撒

2. 老大，俺 想问一哈，咱这里有木有CAJ转WORD的转换器啊？俺从知网下载的文件都是CAJ格式的，咱这里只看到了PDF的转换器，老大帮帮忙撒

3. 老大，俺 想问一哈，咱这里有木有CAJ转WORD的转换器啊？俺从知网下载的文件都是CAJ格式的，咱这里只看到了PDF的转换器，老大帮帮忙撒

4. 老大，俺 想问一哈，咱这里有木有CAJ转WORD的转换器啊？俺从知网下载的文件都是CAJ格式的，咱这里只看到了PDF的转换器，老大帮帮忙撒

5. 老大，俺 想问一哈，咱这里有木有CAJ转WORD的转换器啊？俺从知网下载的文件都是CAJ格式的，咱这里只看到了PDF的转换器，老大帮帮忙撒

6. 老大，俺 想问一哈，咱这里有木有CAJ转WORD的转换器啊？俺从知网下载的文件都是CAJ格式的，咱这里只看到了PDF的转换器，老大帮帮忙撒

7. 老大，俺 想问一哈，咱这里有木有CAJ转WORD的转换器啊？俺从知网下载的文件都是CAJ格式的，咱这里只看到了PDF的转换器，老大帮帮忙撒

8. 老大，俺 想问一哈，咱这里有木有CAJ转WORD的转换器啊？俺从知网下载的文件都是CAJ格式的，咱这里只看到了PDF的转换器，老大帮帮忙撒

9. 老大，俺 想问一哈，咱这里有木有CAJ转WORD的转换器啊？俺从知网下载的文件都是CAJ格式的，咱这里只看到了PDF的转换器，老大帮帮忙撒

10. 老大，俺 想问一哈，咱这里有木有CAJ转WORD的转换器啊？俺从知网下载的文件都是CAJ格式的，咱这里只看到了PDF的转换器，老大帮帮忙撒

11. 老大，俺 想问一哈，咱这里有木有CAJ转WORD的转换器啊？俺从知网下载的文件都是CAJ格式的，咱这里只看到了PDF的转换器，老大帮帮忙撒

12. 老大，俺 想问一哈，咱这里有木有CAJ转WORD的转换器啊？俺从知网下载的文件都是CAJ格式的，咱这里只看到了PDF的转换器，老大帮帮忙撒

13. 老大，俺 想问一哈，咱这里有木有CAJ转WORD的转换器啊？俺从知网下载的文件都是CAJ格式的，咱这里只看到了PDF的转换器，老大帮帮忙撒

14. 这个官员看来也是个网瘾很大的网虫,网民言语有偏激,你也和网民们一样言语偏激,你比网民强到哪儿去?网民没脑子你就有么?这官是怎么当上的,显示智商不足.

15. 这个官员看来也是个网瘾很大的网虫,网民言语有偏激,你也和网民们一样言语偏激,你比网民强到哪儿去?网民没脑子你就有么?这官是怎么当上的,显示智商不足.

16. 这个官员看来也是个网瘾很大的网虫,网民言语有偏激,你也和网民们一样言语偏激,你比网民强到哪儿去?网民没脑子你就有么?这官是怎么当上的,显示智商不足.

17. 这个官员看来也是个网瘾很大的网虫,网民言语有偏激,你也和网民们一样言语偏激,你比网民强到哪儿去?网民没脑子你就有么?这官是怎么当上的,显示智商不足.

18. 这个官员看来也是个网瘾很大的网虫,网民言语有偏激,你也和网民们一样言语偏激,你比网民强到哪儿去?网民没脑子你就有么?这官是怎么当上的,显示智商不足.

19. 这个官员看来也是个网瘾很大的网虫,网民言语有偏激,你也和网民们一样言语偏激,你比网民强到哪儿去?网民没脑子你就有么?这官是怎么当上的,显示智商不足.

20. 这个官员看来也是个网瘾很大的网虫,网民言语有偏激,你也和网民们一样言语偏激,你比网民强到哪儿去?网民没脑子你就有么?这官是怎么当上的,显示智商不足.

21. 这个官员看来也是个网瘾很大的网虫,网民言语有偏激,你也和网民们一样言语偏激,你比网民强到哪儿去?网民没脑子你就有么?这官是怎么当上的,显示智商不足.

22. 这个官员看来也是个网瘾很大的网虫,网民言语有偏激,你也和网民们一样言语偏激,你比网民强到哪儿去?网民没脑子你就有么?这官是怎么当上的,显示智商不足.

23. 这个官员看来也是个网瘾很大的网虫,网民言语有偏激,你也和网民们一样言语偏激,你比网民强到哪儿去?网民没脑子你就有么?这官是怎么当上的,显示智商不足.

24. 这个官员看来也是个网瘾很大的网虫,网民言语有偏激,你也和网民们一样言语偏激,你比网民强到哪儿去?网民没脑子你就有么?这官是怎么当上的,显示智商不足.