Problem: Aklank is fond of numbers which are divisible by either P1 or P2. He termed those numbers as Bakku numbers. Recently his best friend gave him a range of numbers. Now he is wondering what is the probability of finding Bakku numbers from that range of numbers.

Input
First line of input contains two integers P1 and P2 (2 ≤ P1 ≤ 10000, 2 ≤ P2 ≤ 10000) — both P1 and P2 are prime numbers.

Second line of the input contains an integer T  (1 ≤ T ≤ 100000) — the number of test cases.

Each of the next T lines contains two integers - L and R (1 ≤ L ≤ R ≤ 100,00,00,000) - the starting number and ending number of each range from where he will search for Bakku numbers (inclusive).

Output
Print T lines for each test case.

In each line print answer with up to 6 digits after decimal point.

SAMPLE INPUT
3 5
2
1 10
20 34

SAMPLE OUTPUT
0.500000
0.466667

Explanation

First Case : Numbers divisible by 3 or 5 are 3, 5, 6, 9, 10

Second Case : Numbers divisible by 3 or 5 are 20, 21, 24, 25, 27, 30, 33

Solution (in PYTHON):

Solution:
import sys
from decimal import Decimal as D

def gcd(a,b) :
	if b == 0 : return a
	else : return gcd(b,a%b)

p , q = map(int,sys.stdin.readline().split())
for __ in range(input()) :
	l , r = map(int,sys.stdin.readline().split())
	divp , divq = (r//p)-(l//p) , (r//q)-(l//q)
	"""i = l
	while i <= r :
		if i%p == 0 : 
			divp += 1
			i += p
			continue
		i += 1
	i = l
	while i <= r :
		if i%q == 0 : 
			divq += 1
			i += q
			continue
		i += 1"""
	if l%p == 0 : divp += 1
	if l%q == 0 : divq += 1
	lcm = p*q/(gcd(p,q))
	intersection , i , ans = 0 , lcm , divp+divq
	ans -= ((r/lcm)-(l/lcm))
	print "%.6f"%((ans*1.0)/(r-l+1)*1.0)