An infinite chessboard extends infinitely to the right and upwards. Each cell alternates in color between white and black, with the bottom-left cell being black. Each cell has a side length of millimeters (0 < S \leq 1000).
A grasshopper is positioned at coordinates , where both coordinates are non-negative integers not exceeding 10^5 (measured in millimeters). The grasshopper performs jumps, moving millimeters to the right and millimeters upwards with each jump, that is, from to (x+dx, y+dy), where and are non-negative integers not exceeding .
Determine the minimal number of jumps after which the grasshopper will land on a white cell. Landing exactly on the boundary of cells does not count as landing on a white cell. Note that the grasshopper may never land on a white cell.
The input contains several (at most ) sets of five numbers: , , , , . The input ends with a set of five zeros.
For each set of five numbers in the input, output a single number in a separate line: the required number of jumps, or –1 if it is impossible for the grasshopper to land on a white cell.
Example 1