Milo of Croton and the Calf

No attempts yetTime limit1sMemory limit256 MB

Problem

Milo of Croton was a wrestler who won the Olympic games six times and was famous for his strength. The story goes that he held up the ceiling of a collapsing building until Pythagoras was safely out. One of the ways he built that strength was a training regimen: he carried a calf around the village once a day, and he kept it up until the calf had grown into a full bull.

This problem looks at Milo's regimen a little more carefully. Carrying a young bull around the village has two effects. He is sore for the next few days and can lift less weight, and he builds muscle that lets him lift more weight later. For each day, equivalently for each weight of the calf, you are given two numbers: a permanent strength increase that kicks in 3 days after the exercise, and a soreness penalty that applies on the next 2 days after the exercise. Both the strength increases and the soreness penalties are cumulative. If Milo exercises two days in a row, then on the day after that he is sore from both, and on the second day after that he is sore only from the second exercise while the strength from the first one has arrived.

You are told how much the calf weighed on the first day, how much Milo could lift on the first day, how many days Milo wants to exercise, and what the exercise effects are at each weight of the calf. When Milo's ability to lift equals the weight of the calf he lifts it successfully, but when it is strictly less he fails. Milo exercises every day, and the calf gains one pound every day. Determine whether Milo can finish his entire regimen, and if not, on what day he first fails.

Input

The first line contains the number KK of data sets. The KK data sets follow, each in the form below.

The first line of a data set contains three integers ww, cc, dd separated by spaces. ww is the weight Milo can lift on day 1, with 0w10000 \le w \le 1000. cc is the weight of the calf on day 1, with 0c10000 \le c \le 1000. dd is the number of days Milo plans to exercise, with 1d1001 \le d \le 100.

Then dd lines follow. Line i=1,,di = 1, \dots, d describes the effect of carrying the calf around the village when it weighs c+i1c + i - 1, that is, on day ii. It contains two integers gig_i, sis_i. gig_i is the permanent strength gain from carrying the calf, which kicks in on day i+3i + 3, with 0gi10000 \le g_i \le 1000. sis_i is the soreness penalty, which reduces how much he can lift on days i+1i + 1 and i+2i + 2, with 0si1000 \le s_i \le 100.

Output

For each data set, output Data Set x: on a line by itself, where xx is the number of that data set.

If Milo can finish his entire regimen, output Completed successfully. Otherwise output the number of the first day on which Milo cannot carry the calf any more.

Follow each data set with a blank line.