F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Pty plays game

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 214    Accepted Submission(s): 59


Problem Description
Pty is playing a game, where he is leading a team of soldiers. He is facing a challenge in the game. He plans to complete the challenge x days later.

The monster is also leading a team of soldiers. And to complete the challenge Pty should beat these soldiers.

The battle will execute as follows. At first, the first soldier of both teams will fight first. When a soldier’s hit points becomes 0,the soldier will be replaced by the next soldier in the same team.A team is considered a victory only if there is any soldier alive but nobody is alive in the opposite team finally.

The soldier x have ${h_x}$ hit points and can cause ${d_x}$ damage to the enemy per second. Notice that the seconds of a fight may not be an integer.

Both Pty and the monster will train their soldiers continuously, so the hit points and damage per second of all the soldiers will increase every day.

Pty wants to know the minimum x that he will complete the challenge if it take place on x days later.

If Pty can’t win the monster in $10^{18}$ days, please print none . Specially, if Pty can win now, the answer is 0.
 

Input
An integer T in the first line, it is the number of tesecases. And there are T cases later.

In each case, two integers in the first line n,m, which is the numbers of soldiers in the Pty’s team and the monster’s team.

In the next n lines, each line contains 4 integers. They means the hit point, the increment of hit point every day, the damage and the increment of damage every day.

In the next m lines, also contains 4 integers. They are the information of the soldier in the monster’s team.

$(1 \leq n,m\leq 10^5, \sum (n+m) \leq 2\times 10^6,0 \leq h_x,d_x \leq 10^6,0\leq increment \leq 10^3)$
 

Output
For each test case, output ’none’ or integer means the minimum of x in one line.
 

Sample Input
2 3 2 2 3 1 3 3 2 4 3 1 2 2 3 3 3 4 2 4 1 1 3 1 1 1 1 1 1 1 1 1 1
 

Sample Output
1 none
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-18 17:13:56, Gzip enabled