Roads of the Empire

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

King is dead. Long live the king!

The young emperor has just inherited the vast empire of his father. After the successful reign, it consists of such many cities that it is plausible to consider that there are infinitely many of them.

However, the transportation system of the empire is pretty poor. As all new rulers do, the emperor wants to change his predecessor's policies. Thus, instead of war, he decides to build some new roads in the empire. However, the country's religious beliefs require the emperor to follow a specific ritual of building new roads.

First, he has to choose a positive number nn. Then, nn cities are taken, numbered from 11 to nn. After that, for all pairs of cities with numbers xx and yy such that 1x<yn1 \leq x < y \leq n, the road between them is built if and only if x+nx + n is evenly divisible by yy

After all those manipulations, the emperor has to choose two cities uu and vv, satisfying 1u,vn1 \leq u, v \leq n, and find the number of roads in the shortest path between them. Moreover, he must choose them randomly and equiprobably to be blessed by God, the holy protector of the empire. Knowing this length, the Religious Council will decide whether the plan is acceptable. 

The emperor is worried before the meeting with the Council, so he prepared several such plans. For every plan, answer the question of the length of the shortest path!

입력

The first line contains one integer TT (1T21051 \leq T \leq 2 \cdot 10^5) --- the number of plans proposed by the emperor.

Each of the following TT lines contains three integers n,u,vn, u, v (1n1018,1u,vn1 \leq n \leq 10^{18}, 1 \leq u, v \leq n) --- the number of cities chosen for the plan, and the two cities for which you are asked to find the length of the shortest path in the described graph.

It is guaranteed that uu and vv were chosen randomly and equiprobably after nn had been selected for each test.

출력

For every query, print a number on a separate line --- the length of the shortest path between the corresponding cities. If the path does not exist, print 1-1.