H. Prime Topology
time limit per test
1 second
memory limit per test
960 megabytes
input
standard input
output
standard output
Example
Input
3
5 2
6 3
10000000 10000000
Output
5
2
0