P17740 [HackerEarth] Ross, being divorced for three times(yeah, and he is just 30!) had nothing to do so Chandler told him to paint his apartment.
普及
题目描述

Ross, being divorced for three times(yeah, and he is just 30!) had nothing to do so Chandler told him to paint his apartment.
Consider the wall is made with labelled bricks 1, 2, 3,.... and so on. Now after choosing Red paint for Ross and Blue for Chandler, they started painting a wall, Ross said he will paint every Xth brick Red, i.e., for some X, he will paint X, 2X, 3X,... etc Red. Similarly Chandler said that he will paint every Yth brick Blue. For some Y, he will paint Y,2Y,3Y,...

After painting the wall they found that some of bricks were painted both Red and Blue. Now they are wondering How many bricks from Brick number A to Brick number B are colored with both colors.

Now it's you to help them telling the number of bricks painted with both colors.

Input

First line T, number of test case then T lines, one test case per line.

Each test case, Four integers space separated integers X,Y,A,B.

Output

For each test case, print the described output in newline.

Constraints

1 ≤ T ≤ 50

1 ≤ X, Y ≤ 1000

1 ≤ A ≤ B ≤ 2·(10^9)

SAMPLE INPUT
3
1 3 4 5
2 4 4 8
3 6 2 12

SAMPLE OUTPUT
0
2
2

Explanation

Case 1: for X=1, Ross will paint all bricks, Y=3, Chandler will paint 3,6,9.... hence none in range [4,5] will be painted by both.

Case 2: X=2, Y=4, so 4th and 8th will be painted by both so output 2.

输入格式

见题面

输出格式

见题面

样例输入
6 2 3 6 18 4 6 20 201 15 27 100 10000 105 60 3456 78910 1 1 1000 100000 3 2 5 5
样例输出
1000000001 1000000000 1999999999 333333333 1 0 2