Q10620: A flea on a chessboard

有一塊無限大的西洋棋盤(黑白相間棋格),左下角那格為黑色且每個格子的邊長為 S (0 < S < 1000)公分,另外我們訂左下角的座標訂為 (0,0)。有一隻跳蚤位於棋盤上的某個座標位置 (x, y),他每次跳一定是往上 dx 公分,往右 dy 公分(0 < dx, dy),也就是說,跳蚤跳一次後的座標位置為 ( x+dx, y+dy )。

給你跳蚤一開始在棋盤上的座標,你的任務是算出跳蚤要跳多少次後,會到達白色的格子。請注意:假如跳蚤落在兩格之間的格線上,並算落在白色格子中。也請注意,跳蚤有可能永遠也達不到白色格子

Input

每組測試資料一列。含有 5 個不為負數的整數  S, x, y, dx, dy。其意義如題目所述。

若這5個數均為 0 代表輸入結束。

Output

對每組測試資料輸出一列,輸出內容及格式請參考Sample Output。

Sample Input Sample Output
10 2 3 3 2
100 49 73 214 38
25 0 0 5 25
407 1270 1323 1 1
18 72 6 18 6
407 1270 1170 100 114
0 0 0 0 0
After 3 jumps the flea lands at (11, 9).
After 1 jumps the flea lands at (263, 111).
The flea cannot escape from black squares.
After 306 jumps the flea lands at (1576, 1629).
The flea cannot escape from black squares.
After 0 jumps the flea lands at (1270, 1170).