#P1295D. Same GCDs
Same GCDs
No submission language available for this problem.
Description
You are given two integers and . Calculate the number of integers such that and .
Note: is the greatest common divisor of and .
The first line contains the single integer () — the number of test cases.
Next lines contain test cases — one per line. Each line contains two integers and ().
Print integers — one per test case. For each test case print the number of appropriate -s.
Input
The first line contains the single integer () — the number of test cases.
Next lines contain test cases — one per line. Each line contains two integers and ().
Output
Print integers — one per test case. For each test case print the number of appropriate -s.
Samples
Note
In the first test case appropriate -s are .
In the second test case the only appropriate is .