Loading [MathJax]/jax/output/HTML-CSS/jax.js

UOFTBB - Attack of the Bloons

The Bloons (not to be confused with balloons) are attacking! They are attempting to navigate your course of L (1L1000) cells, laid out in a row and numbered from 1 to L. You don't know what they'll do to you if they manage reach the end, and you don't want to find out! To that end, you've constructed some defensive towers along the course. You might say that this is a Bloons Tower Defense.

There are N (1N1000) towers ready to take out any Bloons that get close. The ith tower is located next to cell Ci (1CiL), and can launch darts at any Bloons that are no more than Ri (0Ri1000) cells away - that is, Bloons in cells CiRi to Ci+Ri, inclusive. Every second, it will do Di (1Di109) HP worth of damage to any Bloons in this range.

M (1M1000) Bloons will attempt to float through your course, one after another. The ith Bloon begins with Hi (1Hi109) HP, and will pop as soon as it has taken at least that much damage in total. Each Bloon starts in cell 1, and moves along the course at a speed of 1 cell per second. If a Bloon moves past cell L, it safely exits the course and can no longer be popped.

There are T (1T20) scenarios as described above. For each, you'd like to determine how far along the course each of the M Bloons will make it.

Input

First line: 1 integer, T

For each scenario:

First line: 2 integers, L and N

Next N lines: 3 integers, Ci, Ri, and Di, for i=1..N

Next line: 1 integer, M

Next M lines: 1 integer, Hi, for i=1..M

Output

For each scenario:

M lines: If the ith Bloon will survive the course, the string "Bloon leakage" (without quotes) - otherwise, 1 integer, the furthest cell which the ith Bloon will reach, for i=1..M

Example

Input:
1
10 3
3 3 1
4 0 4
10 2 2
4
1
20
9
11
Output: 1
Bloon leakage
5
8

Explanation of Sample:

The following diagram illustrates which cells each tower can hit:

The first Bloon, having only 1 HP, will go down to the first tower in cell 1.

The second Bloon will manage to clear the course, surviving past cell 10 with 4 HP remaining.

The third Bloon will lose its final HP while at cell 5, having taken 5 damage from the first tower, and 4 from the second.

The final Bloon will survive past cell 6 with 1 HP remaining, but will then go down at cell 8 when it takes 2 damage from the third tower.


Added by:SourSpinach
Date:2013-05-17
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Own problem, used in the 2012 UofT ACM Tryouts

hide comments
2013-06-21 19:24:58 Himanshu
@atul kumar verma
thanx a lot.......
2013-06-14 18:26:29 shiv prasad chabarval
easy one
2013-06-09 21:48:14 Vipul Pandey
not a difficult one but it is worth to be in classical.
2013-06-02 17:09:56 Rishikesh Jha
@Ouditchya Sinha : Is there a tough problem for you?
2013-06-02 09:40:16 Ouditchya Sinha
Easy problem. :)
2013-05-29 08:08:58 Vijay Jain
tutorial stuff...
2013-05-29 04:42:58 (^_^)
simple :)
2013-05-23 08:52:48 rise..!!
move to tutorial :P
2013-05-22 22:46:50 biQar
If you consider to increase the ranges of the problem, then it can be a very nice one. :)

RE: I'll keep the original bounds - this problem wasn't supposed to be too hard. The most trivial solution fails, though.

Last edit: 2013-05-23 02:09:05
2013-05-22 17:55:51 Eduardo Nunes
lol, mistake with range gave me 5 WAs :-( finallly AC! :D
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.