#P2257. YY的GCD

YY的GCD

Description

After studying number theory, YY gave kAc a problem.

Given N,MN, M, find the number of pairs (x,y)(x, y) such that 1xN1 \leq x \leq N, 1yM1 \leq y \leq M, and gcd(x,y)\gcd(x, y) is a prime.

Input Format

The first line contains an integer TT denoting the number of test cases.

Then follow TT lines, each containing two positive integers N,MN, M.

Output Format

Output TT lines, each containing one integer, the answer for the ii-th test case.

2
10 10
100 100
30
2791

Hint

T=104T = 10^4, N,M107N, M \leq 10^7.

Translated by ChatGPT 5