# Function to simulate the water flow and check if the dam overflows or runs out def check_dam(V, X, Fo, Fi, Q, R): t = 0 water_level = X while True: # Check if the dam overflows if water_level > V: return "Overflow" # Check if the dam runs out of water if water_level <= 0: return "Zero" # Simulate water outflow water_level -= Fo # Check if there's a rainfall event if t % Q == 0: water_level += Fi # Increment time t += 1 # Read the number of test cases T = int(input()) # Iterate over each test case for _ in range(T): # Read input parameters for the test case V, X, Fo, Fi, Q, R = map(int, input().split()) # Call the function to check the dam status for the current test case result = check_dam(V, X, Fo, Fi, Q, R) # Output the result print(result)