Bakery

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

Bessie has opened a bakery!

In her bakery, Bessie has an oven that can produce a cookie in t_Ct\_C units of time or a muffin in t_Mt\_M units of time (1t_C,t_M1091\le t\_C,t\_M\le 10^9). Due to space constraints, Bessie can only produce one pastry at a time, so to produce AA cookies and BB muffins, it takes At_C+Bt_MA \cdot t\_C + B \cdot t\_M units of time.

Bessie's NN (1N1001\le N\le 100) friends would each like to visit the bakery one by one. The iith friend will order a_ia\_i (1a_i1091 \leq a\_i\leq 10^9) cookies and b_ib\_i (1b_i1091 \leq b\_i \leq 10^9) muffins immediately upon entering. Bessie doesn't have space to store pastries, so she only starts making pastries upon receiving an order. Furthermore, Bessie's friends are very busy, so the iith friend is only willing to wait c_ic\_i (a_i+b_ic_i21018a\_i + b\_i \leq c\_i \leq 2 \cdot 10^{18}) units of time before getting sad and leaving.

Bessie really does not want her friends to be sad. With one mooney, she can upgrade her oven so that it takes one less unit of time to produce a cookie or one less unit of time to produce a muffin. She can't upgrade her oven a fractional amount of times, but she can choose to upgrade her oven as many times as she needs before her friends arrive, as long as the time needed to produce a cookie and to produce a muffin both remain strictly positive.

For each of TT (1T1001 \leq T \leq 100) test cases, please help Bessie find out the minimum amount of moonies that Bessie must spend so that her bakery can satisfy all of her friends.

입력

The first line contains TT, the number of test cases.

Each test case starts with one line containing NN, t_Ct\_C, t_Mt\_M. Then, the next NN lines each contain three integers a_i,b_i,c_ia\_i,b\_i, c\_i.

Consecutive test cases are separated by newlines.

출력

The minimum amount of moonies that Bessie needs to spend for each test case, on separate lines.