ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

Open Ural FU Personal Contest 2012

About     Problems     Submit solution     Judge status     Standings
Contest is over

H. The Robot on the Line

Time limit: 1.0 second
Memory limit: 64 MB
Robotics is very popular on the planet T4-F7 of star system of Tau Ceti. Professor Bobov has recently demonstrated his new development—an autonomous robot which can move in one dimension. The robot’s program receives a real number x as input, which specifies the robot’s behavior in the future completely. At the first second the robot covers distance f(x) = ax2 + bx + c (if f(x) is positive, it moves to the right, and if it is negative, the robot moves to the left). During the next second the robot covers distance f(x + 1), during the third second it covers distance f(x + 2) and so on.
For the presentation, professor Bobov wants to make sure that the robot will come back to the initial position in exactly k seconds after start of its program. So there is a question if any suitable x exists. It may simply turn out that for any input data the robot can’t come back to the initial point in k seconds. Help professor Bobov finding the minimum k which allows this to happen.

Input

The first line contains an integer t (1 ≤ t ≤ 1 000) that is the number of tests. Each of the next t lines contains another test, i.e., integers a, b, c specifying the behavior of the robot. Numbers a, b, c are less than 109 by absolute value. Number a is positive.

Output

For every test, output the minimal positive integer k for which there is no parameter x getting the robot back to the initial position in k seconds. If there is no such k or it is larger than 1018, output “Infinity”.

Sample

inputoutput
2
1 -2 1
1 1 -6
2
9
Problem Author: Andrey Demidov
Problem Source: Open Ural FU Personal Contest 2012
To submit the solution for this problem go to the Problem set: 1948. The Robot on the Line