Watson likes to challenge Sherlock's math ability.  He will provide a starting and ending value that describe a range of integers, inclusive of the endpoints.  Sherlock must determine the number of square integers within that range.

Note: A square integer is an integer which is the square of an integer, e.g. $1,4,9,16,25$. 

Example 

$a=24$ 

$b=49$  

There are three square integers in the range: $25,36$ and $49$.  Return $3$.   

Function Description

Complete the squares function in the editor below.  It should return an integer representing the number of square integers in the inclusive range from $a$ to $b$.  

squares has the following parameter(s):  

int a: the lower range boundary
int b: the upper range boundary  

Returns  

int: the number of square integers in the range

Input Format

The first line contains $q$, the number of test cases. 

Each of the next $q$ lines contains two space-separated integers, $a$ and $b$, the starting and ending integers in the ranges.     

Constraints

$1\leq q\leq100$ 

$1\leq a\leq b\leq10^9$  

Sample Input
2
3 9
17 24

Sample Output
2
0

Explanation

Test Case #00: In range $[3,9]$, $4$ and $9$ are the two square integers. 

Test Case #01: In range $[17,24]$, there are no square integers.

Difficulty: EASY
Tags: Implementation

Starter code:

Solutions:
import sys
T = int(sys.stdin.readline())
for _ in range(T):
	(A, B) = list(map(int, sys.stdin.readline().split()))
	nA = int(A ** 0.5)
	nB = int(B ** 0.5)
	ans = int(B ** 0.5) - int(A ** 0.5)
	if nA ** 2 == A:
		ans += 1
	print(ans)


import math
T = int(input())
for t in range(T):
	(A, B) = [int(v) for v in input().split()]
	ar = math.ceil(math.sqrt(A))
	br = math.floor(math.sqrt(B))
	print(br - ar + 1)


from math import sqrt
T = int(input())
for i in range(T):
	count = 0
	inp = [int(a) for a in input().split()]
	c = inp[0]
	while int(sqrt(c)) != sqrt(c) and c < inp[1]:
		c += 1
	while c <= inp[1] and int(sqrt(c)) == sqrt(c):
		count += 1
		c += 2 * sqrt(c) + 1
	print(count)


T = int(input())
N = [map(int, input().split()) for _ in range(T)]
for (a, b) in N:
	c = 0
	i = round(a ** 0.5)
	while i * i <= b:
		if i * i >= a:
			c += 1
		i += 1
	print(c)


n = int(input())
s = []
i = 1
while i ** 2 <= 10 ** 9:
	s.append(i ** 2)
	i += 1
for t in range(n):
	(a, b) = [int(x) for x in input().split(' ')]
	print(len([x for x in s if x >= a and x <= b]))


import math
t = int(input())
for n in range(0, t):
	(a, b) = [int(i) for i in input().strip().split()]
	total = 0
	sqrt_a = math.ceil(math.sqrt(a))
	sqrt_b = math.ceil(math.sqrt(b))
	for val in range(sqrt_a, sqrt_b + 1):
		if math.pow(val, 2) <= b:
			total += 1
	print(total)


import sys
import math
text = sys.stdin.readline()
num_testcase = int(text)
for i in range(num_testcase):
	text = sys.stdin.readline()
	tmp = list(map(int, text.split()))
	a = tmp[0]
	b = tmp[1]
	start = int(math.sqrt(a))
	end = int(math.sqrt(b))
	count = 0
	tmp = start
	while tmp * tmp < a:
		tmp += 1
	start = tmp
	tmp = end - start
	if tmp >= 0:
		count = tmp + 1
	print(count)


import sys
import math
cases = int(sys.stdin.readline())
for i in range(cases):
	line = sys.stdin.readline().split()
	a = math.ceil(math.sqrt(int(line[0])))
	b = int(math.sqrt(int(line[1])))
	sys.stdout.write(str(int(math.fabs(b - a + 1))) + '\n')


import sys
import math
T = int(sys.stdin.readline().rstrip('\n'))
for t in range(T):
	[A, B] = [int(i) for i in sys.stdin.readline().rstrip('\n').split(' ')]
	print(int(math.sqrt(B)) - int(math.sqrt(A - 1)))


def solve(x, y):
	l = x ** (1 / 2)
	l = l // 1
	r = y ** (1 / 2)
	r = r // 1
	result = r - l
	if l * l == x:
		result += 1
	return result
t = int(input())
for i in range(0, t):
	x = input().split()
	a = int(x[0])
	b = int(x[1])
	print(int(solve(a, b)))


import math

def main():
	testcases = int(input())
	for _ in range(testcases):
		(a, b) = [int(x) for x in input().split()]
		(sqrta, sqrtb) = (a ** 0.5, b ** 0.5)
		print(math.floor(sqrtb) - math.ceil(sqrta) + 1)
main()


import math
t = int(input())
for i in range(t):
	(a, b) = [int(x) for x in input().split()]
	(m, n) = (int(math.sqrt(a)), int(math.sqrt(b)))
	res = n - m
	if m ** 2 == a:
		res += 1
	print(res)


from math import *
t = int(input())
for i in range(0, t):
	[a, b] = [int(e) for e in input().split()]
	print(floor(b ** 0.5) - ceil(a ** 0.5) + 1)


import math
t = int(input())

def f():
	s = input().strip().split()
	a = int(s[0])
	b = int(s[1])
	c = int(math.sqrt(a))
	d = int(math.sqrt(b))
	if c == d:
		if c * c == a:
			return 1
		else:
			return 0
	else:
		return int(c * c == a) + d - c
for i in range(t):
	print(f())


import sys
import math
T = int(sys.stdin.readline())
for t in range(T):
	s_line = sys.stdin.readline().split()
	(A, B) = (int(s_line[0]), int(s_line[1]))
	sq_ints = 0
	n = A
	while math.sqrt(n) != int(math.sqrt(n)):
		n += 1
	increment = int(math.sqrt(n)) * 2 + 1
	while n <= B:
		sq_ints += 1
		n += increment
		increment += 2
	print(sq_ints)


import math
T = int(input())
while T > 0:
	(A, B) = [int(x) for x in input().split()]
	counter = 0
	number = 1
	diff = 3
	while number <= B:
		if number >= A:
			counter += 1
		number += diff
		diff += 2
	print(counter)
	T -= 1


import math
t = int(input())
for _ in range(t):
	s = input().split(' ')
	a = int(s[0])
	b = int(s[1])
	c = 0
	x = int(math.sqrt(a))
	if x * x == a:
		c = 1
	x += 1
	while x * x <= b:
		c += 1
		x += 1
	print(c)


t = int(input())
for i in range(0, t):
	count = 0
	(a, b) = [int(j) for j in input().strip().split()]
	square1 = a ** 0.5
	if square1 != int(square1):
		a1 = int(square1) + 1
	else:
		a1 = int(square1)
	square2 = b ** 0.5
	b1 = int(square2)
	count = b1 - a1 + 1
	print(count)


for testcases in range(int(input())):
	two = input().split()
	a = float(two[0]) ** 0.5
	b = float(two[1]) ** 0.5
	if int(a) != a:
		a = int(a) + 1
	b = int(b)
	print(int(b - a + 1))


import math
t = int(input())
for u in range(t):
	line = input().split()
	a = int(line[0])
	b = int(line[1])
	f = math.ceil(math.sqrt(a))
	i = 0
	while pow(f, 2) <= b:
		i += 1
		f += 1
	print(i)


from math import sqrt
n = int(input())
x = []
for i in range(0, n):
	strx = input().split(' ')
	a = int(strx[0])
	b = int(strx[1])
	sa = sqrt(a)
	sb = sqrt(b)
	tot = int(sb) - int(sa)
	if sa == int(sa) or (sa == int(sa) and sb == int(sb)):
		tot = tot + 1
	x.append(tot)
for j in range(0, n):
	print(x[j])


import math
l = [i for i in range(1, 31624)]
sql = [x ** 2 for x in l]

def fun():
	test = input()
	test1 = int(test)
	for i in range(test1):
		ip = input()
		ip1 = ip.split()
		count = 0
		a = int(ip1[0])
		b = int(ip1[1])
		c1 = [j for (j, m) in enumerate(sql) if m >= a][0]
		c2 = [k for (k, n) in enumerate(sql) if n > b][0]
		count = c2 - c1
		print(count)
fun()


from math import *
for T in range(int(input())):
	(A, B) = map(int, input().split())
	(a, b) = (int(ceil(sqrt(A))), int(floor(sqrt(B))))
	print(b - a + 1)


import math
tests = int(input())
for i in range(tests):
	numbers = input().split()
	if math.sqrt(int(numbers[0])) % 1 == 0:
		d = [int(x) for x in range(int(math.sqrt(int(numbers[0]))), int(math.sqrt(int(numbers[1]))) + 1)]
		print(len(d))
	else:
		d = [int(x) for x in range(int(math.sqrt(int(numbers[0]))) + 1, int(math.sqrt(int(numbers[1]))) + 1)]
		print(len(d))


import bisect
sql = list(map(lambda x: x * x, range(100000)))

def sq_num(n):
	return bisect.bisect(sql, n)
T = int(input())
for _ in range(T):
	(A, B) = map(int, input().split())
	print(sq_num(B) - sq_num(A - 1))


from math import sqrt, floor, ceil
for fdds in range(int(input())):
	x = input().split()
	upper = int(x[1])
	lower = int(x[0])
	lr = sqrt(lower)
	ur = sqrt(upper)
	flr = floor(lr)
	fur = ceil(ur)
	ans = fur - flr - 1
	if fur - ur < 1e-16:
		ans += 1
	if lr - flr < 1e-16:
		ans += 1
	print(ans)


import math
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	k = int(math.sqrt(b)) - math.ceil(math.sqrt(a)) + 1
	print(k)


from math import sqrt, floor, ceil
T = int(input())
for test in range(T):
	(A, B) = [int(x) for x in input().split()]
	rootA = ceil(sqrt(A))
	rootB = floor(sqrt(B))
	print(rootB - rootA + 1)


import math

def is_square(n):
	return math.sqrt(n).is_integer()

def is_perfect_square(n):
	nsqrt = math.sqrt(n)
	return nsqrt == math.trunc(nsqrt)

def solve(a, b):
	if a == b:
		return 1
	return math.sqrt(b) - math.sqrt(a) + 1

def nextPerfectSquares(a, b):
	while not is_square(a):
		a = a + 1
	while not is_square(b):
		b = b - 1
	return (a, b)

def next_perfect_squares(a, b):
	x = math.ceil(math.sqrt(a))
	y = math.floor(math.sqrt(b))
	return (x, y)
T = int(input())
for _ in range(0, T):
	(A, B) = [int(i) for i in input().split()]
	(x, y) = next_perfect_squares(A, B)
	if x == y:
		print(1)
	else:
		res = y - x + 1
		print(res)


def count_squares(start, end):
	count = 0
	square_base = int(start ** 0.5)
	if square_base ** 2 >= start:
		count += 1
	square_base += 1
	while square_base ** 2 <= end:
		count += 1
		square_base += 1
	return count
N = int(input())
for i in range(N):
	(s, e) = input().split()
	print(count_squares(int(s), int(e)))


import math

def square(num):
	if int(math.sqrt(num)) ** 2 == num ** 2:
		return True
	else:
		return False

def root(n):
	return math.sqrt(n)
t = int(input())
c = 0
while t > c:
	q = input().split(' ')
	a = int(q[0])
	b = int(q[1])
	if int(root(b)) == int(root(a)) and int(root(b)) != root(b) and (int(root(a)) != root(a)):
		print(0)
	else:
		print(math.floor(root(b)) - math.ceil(root(a)) + 1)
	c += 1


import math as m

def find_nums(lowN, highN):
	lowest = m.ceil(m.sqrt(lowN))
	highest = m.floor(m.sqrt(highN))
	return highest - lowest + 1
numInps = int(input())
lowNum = 0
highNum = 0
inpNums = []
for iter in range(0, numInps):
	inpNums = input().split(' ')
	lowNum = int(inpNums[0])
	highNum = int(inpNums[1])
	print(find_nums(lowNum, highNum))


from math import sqrt
from bisect import *

def find_le(a, x):
	return bisect_right(a, x) - 1

def find_ge(a, x):
	return bisect_left(a, x)

def main():
	n = int(input())
	cache = []
	m = int(sqrt(10 ** 9)) + 1
	for i in range(1, m):
		cache.append(i * i)
	for i in range(n):
		(x, y) = list(map(int, input().split()))
		l = find_ge(cache, x)
		r = find_le(cache, y)
		print(r - l + 1)
main()


import math
num = int(input())
li = []
for x in range(num):
	sa = input().split(' ')
	first = int(sa[0])
	second = int(sa[1])
	baldo = math.ceil(first ** (1 / 2))
	bal2 = math.floor(second ** (1 / 2) + 1)
	li.append(bal2 - baldo)
for thing in li:
	print(thing)


import math

def is_perfect_square(n):
	res = n
	for i in range(1, n + 1, 2):
		res = res - i
		if res < 0:
			return False
		if res == 0:
			return True

def main():
	n = int(input())
	for j in range(n):
		(p, q) = [int(x) for x in input().split()]
		if p > q:
			(p, q) = (q, p)
		n = 0
		for i in range(math.ceil(math.sqrt(p)), math.ceil(math.sqrt(q + 1))):
			if i * i <= q:
				n = n + 1
		print(n)
main()


def main():
	tc = input()
	tc = int(tc)
	ar = []
	for i in range(32000):
		ar.append(i * i)
	for i in range(tc):
		count = 0
		s = input().split()
		a = int(s[0])
		b = int(s[1])
		for i in range(0, 32000):
			if ar[i] >= a and ar[i] <= b:
				count = count + 1
		print(count)
main()


import math
N = int(input())
for i in range(0, N):
	(first, last) = map(int, input().split(' '))
	print(math.floor(math.sqrt(last)) - math.ceil(math.sqrt(first)) + 1)


from math import sqrt, ceil, floor
for i in range(int(input())):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	a = sqrt(a)
	a = ceil(a)
	b = sqrt(b)
	b = int(b)
	print(b - a + 1)


n = int(input())
for i in range(n):
	(a, b) = [int(x) for x in input().split()]
	if a == b:
		if int(a ** 0.5) ** 2 == a:
			print(1)
		else:
			print(0)
	else:
		y = int(b ** 0.5) - int((a - 1) ** 0.5)
		print(y)


import math
for i in range(int(input())):
	counter = 0
	(a, b) = [int(x) for x in input().split()]
	print(math.floor(b ** 0.5) - math.ceil(a ** 0.5) + 1)


import math
T = int(input())
for _ in range(T):
	(a, b) = [float(x) for x in input().split()]
	(ra, rb) = [math.sqrt(x) for x in [a, b]]
	res = rb.__trunc__() - ra.__trunc__()
	if ra.is_integer():
		print(res + 1)
	else:
		print(res)


import sys
import math
T = int(sys.stdin.readline())
for test_case in range(T):
	data = sys.stdin.readline().rstrip().split()
	A = int(data[0])
	B = int(data[1])
	i = math.ceil(A ** (1 / 2))
	end = math.floor(B ** (1 / 2))
	square_numbers = end - i + 1
	print(square_numbers)


t = int(input())
for i in range(t):
	(A, B) = map(int, input().split())
	(a, b) = (A ** 0.5, B ** 0.5)
	c = 0
	if a != int(a):
		a = int(a) + 1
	else:
		a = int(a)
	b = int(b)
	for m in range(a, b + 1):
		if m ** 2 <= B:
			c += 1
		else:
			break
	print(c)


T = int(input())
for x in range(T):
	(a, b) = map(int, input().split())
	(c, i) = (0, 0)
	while i * i <= b:
		if i * i >= a:
			c += 1
		i += 1
	print(c)


import math
n = int(input())
for i in range(n):
	inp = input().split()
	x = int(inp[0])
	y = int(inp[1])
	rt_x = int(math.sqrt(x))
	rt_y = int(math.sqrt(y))
	sqr_x = rt_x ** 2
	sqr_y = rt_y ** 2
	if sqr_x == x and sqr_y == y or (sqr_x == x and sqr_y != y):
		print(rt_y - rt_x + 1)
	else:
		print(rt_y - rt_x)


cases = int(input())
for _ in range(cases):
	(count, i, condition) = (0, 1, True)
	(a, b) = [int(x) for x in input().split()]
	while condition:
		if i * i > b:
			condition = False
		else:
			if i * i >= a:
				count += 1
			i += 1
	print(count)


__author__ = 'jeffmcgraw'
from math import sqrt
from math import floor
from math import ceil

def read_line():
	line_list = []
	line_string = input()
	for a in line_string.split(' '):
		b = int(a)
		line_list.append(b)
	return line_list

def square_count(test_line):
	start = test_line[0]
	end = test_line[1]
	output = floor(sqrt(end)) - ceil(sqrt(start)) + 1
	return output

def main():
	for num_test in range(int(input())):
		line = sorted(read_line())
		print(square_count(line))
main()


from math import sqrt
t = int(input())
for u in range(t):
	line = input().split()
	a = int(line[0])
	b = int(line[1])
	c = int(sqrt(a))
	b = int(sqrt(b))
	if c * c == a:
		c = c - 1
	print(b - c)


import math
t = int(input())
testCase = list()
for i in range(0, t):
	testCase.append(input())
for i in range(0, t):
	a = float(testCase[i].split()[0])
	b = float(testCase[i].split()[1])
	start = math.floor(math.sqrt(a))
	end = math.ceil(math.sqrt(b))
	count = 0
	for i in range(start, end + 1):
		calcsq = i * i
		if calcsq >= a and calcsq <= b:
			count = count + 1
	print(count)


import math

def squares_between(a, b):
	count = math.floor(math.sqrt(b)) - math.floor(math.sqrt(a - 1))
	return count
test_count = int(input())
for _ in range(test_count):
	(a, b) = tuple((int(pair) for pair in input().split()))
	print(squares_between(a, b))


def solve():
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	la = a ** (1 / 2)
	lb = b ** (1 / 2)
	la = int(la)
	lb = int(lb)
	c = 0
	if la * la != a:
		la += 1
	if lb > la:
		c = 1 + (lb - la)
	elif lb == la:
		c = 1
	print('%d' % c)
t = int(input())
for i in range(0, t):
	solve()


import sys
import math
cases = int(sys.stdin.readline().strip())
for i in range(cases):
	test = sys.stdin.readline().split()
	lil = int(test[0])
	big = int(test[1])
	squares = 0
	first = math.ceil(lil ** 0.5) ** 2
	if first <= big:
		inside = True
	else:
		inside = False
	while inside == True:
		if (first ** 0.5 + squares) ** 2 <= big:
			squares += 1
		else:
			inside = False
	print(squares)


numCases = int(input())
for i in range(numCases):
	(a, b) = [int(i) for i in input().split()]
	squares = []
	idx = 1
	sq = 0
	while True:
		sq = idx ** 2
		if sq >= a:
			break
		idx += 1
	while sq <= b:
		squares.append(idx)
		idx += 1
		sq = idx ** 2
	print(len(squares))


from math import *
g = int(input())
while g:
	count = 0
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	(c, d) = (sqrt(a), sqrt(b))
	(c, d) = (int(c), int(d))
	if c == sqrt(a):
		e = d - c + 1
		print(e)
	else:
		e = d - c
		print(e)
	g -= 1


import math
row = int(input())
for i in range(0, row):
	count = 0
	val = input()
	val = val.split(' ')
	low = int(val[0])
	high = int(val[1])
	low1 = int(math.sqrt(low))
	a = low1 ** 2
	l = range(low, high + 1)
	while a <= high:
		if a in l:
			count += 1
		low1 += 1
		a = low1 ** 2
	print(count)


from math import sqrt
for i in range(int(input())):
	(A, B) = map(int, input().split())
	R = sqrt(A)
	C = -int(int(R) != R)
	while True:
		C += 1
		R = int(R) + 1
		S = R ** 2
		if S > B:
			break
	print(C)


import math
case = int(input())
for j in range(0, case):
	tmp = input().split()
	(i, square, a, b) = (1, 0, int(tmp[0]), int(tmp[1]))
	while i * i <= b:
		if (i * i >= a) & (i * i <= b):
			square = square + 1
		i = i + 1
	print(square)


import math

def get_input():
	num_testcases = int(input())
	test_array = []
	for testcase in range(num_testcases):
		test_array.append([int(i) for i in input().split()])
	return test_array

def count_squares(test_array):
	for testcase in test_array:
		first_sqrt = int(math.sqrt(testcase[0]))
		last_sqrt = int(math.sqrt(testcase[1]))
		num_squares = last_sqrt - first_sqrt
		if testcase[0] == first_sqrt ** 2:
			num_squares += 1
		print(num_squares)

def run_test():
	test_array = get_input()
	count_squares(test_array)
run_test()


from math import sqrt, floor, ceil
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print(floor(sqrt(b)) - ceil(sqrt(a)) + 1)


import math
T = int(input())
for _ in range(T):
	(A, B) = tuple([int(x) for x in input().split()])
	b = math.sqrt(B)
	a = math.sqrt(A)
	extra = 1 if math.floor(a) == a else 0
	print(int(b) - int(a) + extra)


from math import sqrt, ceil, floor
num_tests = int(input())
for i in range(num_tests):
	(a, b) = list(map(int, input().split(' ')))
	s_a = ceil(sqrt(a))
	s_b = floor(sqrt(b))
	print(s_b - s_a + 1)


N = int(input())
for i in range(N):
	(A, B) = list(map(int, input().split(' ')))
	(low, high) = (int(A / 2), int(B / 2))
	al = []
	for i in range(1, B + 1):
		a = i * i
		if a >= A and a <= B:
			al.append(a)
		elif a > B:
			break
	print(len(al))


T = int(input())
for i in range(T):
	(a, b) = list(map(int, input().split()))
	a = a ** 0.5
	b = b ** 0.5
	if not a.is_integer():
		a = int(a) + 1
	else:
		a = int(a)
	b = int(b)
	print(b - a + 1)


from math import sqrt
for n in range(int(input())):
	count = 0
	(l, h) = map(int, input().split())
	x = sqrt(l)
	c = x - int(x)
	if c != 0.0:
		c = 0
	else:
		c = 1
	print(int(sqrt(h)) - int(sqrt(l)) + c)


from math import sqrt
for _ in range(int(input())):
	(A, B) = [int(x) for x in input().split()]
	print(int(sqrt(B)) - int(sqrt(A - 1)))


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	(A, B) = list(map(int, sys.stdin.readline().split()))
	nA = int(A ** 0.5)
	nB = int(B ** 0.5)
	print(nB - nA + (1 if nA ** 2 == A else 0))


from math import *
t = int(input())
for i in range(t):
	line = input().split(' ')
	a = int(line[0])
	b = int(line[1])
	count = int(sqrt(b)) - int(sqrt(a))
	if int(sqrt(a)) * int(sqrt(a)) == a:
		count += 1
	print(count)


def isqrt(n):
	(x, y) = (n, 1)
	while y < x:
		x = x + y >> 1
		y = n // x
	return x
T = int(input())
for _ in range(T):
	(A, B) = [int(_) for _ in input().split()]
	a = isqrt(A - 1)
	b = isqrt(B)
	print(b - a)


import math
T = int(input())
assert 1 <= T <= 100
for _ in range(T):
	(A, B) = input().split()
	(A, B) = (int(A), int(B))
	assert 1 <= A <= B <= 10 ** 9
	k = 0
	first = math.floor(math.sqrt(A))
	last = math.ceil(math.sqrt(B))
	for i in range(first, last + 1):
		j = i ** 2
		if j in range(A, B + 1):
			k = k + 1
	print(k)


T = int(input())
for i in range(T):
	[A, B] = map(int, input().split(' '))
	minsquare = int(A ** 0.5 + 0.5)
	maxsquare = int(B ** 0.5)
	result = maxsquare - minsquare + 1
	if minsquare ** 2 < A:
		result -= 1
	if maxsquare ** 2 > B:
		result -= 1
	print(result)


import math
t = int(input())
while t > 0:
	u = []
	ans = 0
	s = input()
	for str in s.split():
		u.append(int(str))
	a = u[0]
	b = u[1]
	start = math.ceil(math.sqrt(a))
	end = math.floor(math.sqrt(b))
	for i in range(start, end + 1):
		ans += 1
	t -= 1
	print(ans)


import math

def get_num_squares(a, b):
	a_base = math.sqrt(a)
	b_base = math.sqrt(b)
	num_squares = math.floor(b_base) - math.floor(a_base)
	if a_base == b_base and b_base - math.floor(b_base) == 0 or a_base - math.floor(a_base) == 0:
		num_squares += 1
	return num_squares
T = int(input())
for t in range(T):
	(a, b) = [int(x) for x in str(input()).split(' ')]
	print(get_num_squares(a, b))


import math

def add_roots(floor, ceil):
	root = int(math.sqrt(floor))
	candidate = root
	while True:
		power = root * root
		roots[root] = power
		if power < ceil:
			root += 1
		else:
			break

def find_square(number):
	if number > max(roots.keys()):
		add_roots
n = int(input())
cases = []
roots = {}
while n > 0:
	cases.append(input())
	n -= 1
for case in cases:
	roots = {}
	nums = str.split(case)
	count = 0
	a = int(nums[0])
	b = int(nums[1])
	add_roots(a, b)
	squares = sorted(roots.values())
	for square in squares:
		if square >= a and square <= b:
			count += 1
	print(count)


import math

def f(a, b):
	return int(math.floor(math.sqrt(b)) - math.ceil(math.sqrt(a)) + 1)
for _ in range(int(input())):
	print(f(*[int(i) for i in input().split()]))


from math import *
t = int(input())
while t:
	a = input()
	a = a.split()
	b = int(a[0])
	c = int(a[1])
	i = int(sqrt(b))
	count = 0
	while i:
		x = i * i
		if x <= c and x >= b:
			count += 1
		if x > c:
			break
		i += 1
	print(count)
	t -= 1


import math
N = int(input())
for i in range(N):
	numbers = input().split(' ')
	a = int(numbers[0])
	b = int(numbers[1])
	a2 = math.ceil(math.sqrt(a))
	b2 = int(math.sqrt(b))
	print(b2 - a2 + 1)


for i in range(int(input())):
	(a, b) = (int(x) for x in input().split())
	(sra, srb) = (int(a ** 0.5), int(b ** 0.5))
	if sra ** 2 < a:
		sra += 1
	print(srb - sra + 1)


import math
n = int(input())
for _ in range(n):
	temp = input().split()
	a = int(temp[0])
	b = int(temp[1])
	i = math.ceil(math.sqrt(a))
	num = 0
	while i * i <= b:
		num = num + 1
		i = i + 1
	print(num)


num = int(input(''))
for lc in range(0, num):
	line = input('').split(' ')
	a = int(line[0])
	b = int(line[1])
	sq = 1
	ad = 3
	c = 0
	while sq < a:
		sq += ad
		ad += 2
	while a <= sq <= b:
		sq += ad
		ad += 2
		c += 1
	print(c)


import math

def solve(start, end):
	return int(math.floor(math.sqrt(end)) - math.ceil(math.sqrt(start)) + 1)
cases = int(input())
for _ in range(cases):
	case = [int(x) for x in input().split()]
	print(solve(*case))


from sys import stdin
from math import floor, ceil, sqrt
cases_count = int(stdin.readline())
for case_number in range(cases_count):
	(a, b) = list(map(int, stdin.readline().split()))
	(isqrt_a, isqrt_b) = (int(ceil(sqrt(a))), int(floor(sqrt(b))))
	if isqrt_a > isqrt_b:
		print(0)
	else:
		print(isqrt_b - isqrt_a + 1)


n = int(input())
for _ in range(n):
	(a, b) = input().split(' ')
	(a, b) = (int(a), int(b))
	count = 0
	for i in range(int(a ** 0.5), int(b ** 0.5) + 1):
		if i * i >= a and i * i <= b:
			count += 1
	print(count)


def main():
	n = int(input(''))
	for i in range(n):
		[x, y] = list(map(int, input('').split(' ')))
		low = pow(x, 0.5)
		square = 0
		if low % 1 == 0:
			square = 1
		low = int(low)
		high = int(pow(y, 0.5))
		if low < 0:
			low = 0
		if high < 0:
			high = 0
		print(high - low + square)
main()


for t in range(int(input())):
	total = 0
	x = 0
	(a, b) = [int(x) for x in input().split()]
	while True:
		x += 1
		y = x ** 2
		if y > b:
			break
		if y >= a:
			total += 1
	print(total)


from math import *
N = int(input())
for x in range(N):
	(a, b) = input().strip().split()
	a = ceil(sqrt(float(a)))
	b = floor(sqrt(float(b)))
	print(int(b - a + 1))


import math

def number_of_squares(A, B):
	count = math.floor(math.sqrt(B)) - math.floor(math.sqrt(A - 1))
	return count
T = int(input())
for _ in range(T):
	(A, B) = tuple((int(pair) for pair in input().split()))
	print(number_of_squares(A, B))


from math import *
n_cases = int(input())
for nc in range(n_cases):
	(a, b) = map(int, input().split())
	sq_cnt = 0
	for i in range(1, int(sqrt(b) + 1)):
		sqi = i * i
		if a <= sqi <= b:
			sq_cnt += 1
	print(sq_cnt)


import math
T = int(input())
for test in range(T):
	(start, end) = [int(x) for x in input().split()]
	if end < 0:
		print(0)
	else:
		if start < 0:
			start = 0
		start = math.ceil(math.sqrt(start))
		count = 0
		while start < 0 or start ** 2 <= end:
			count += 1
			start += 1
		print(count)


def sherlock(case):
	(A, B) = case
	minimum = int(A ** 0.5)
	count = 0
	while minimum ** 2 <= B:
		if minimum ** 2 >= A:
			count += 1
		minimum += 1
	print(count)
cases = int(input())
for i in range(cases):
	sherlock([int(i) for i in input().split()])


import math
T = int(input())
for i in range(T):
	(A, B) = [int(x) for x in str(input()).split()]
	answer = 0
	a = math.ceil(math.sqrt(A))
	b = math.floor(math.sqrt(B))
	print(1 + b - a)


import math
t = int(input())
for _ in range(t):
	(start, stop) = map(int, input().split())
	count = 0
	sqrt_start = math.ceil(math.sqrt(start))
	sqrt_stop = math.floor(math.sqrt(stop))
	print(sqrt_stop - sqrt_start + 1)


import math

def main():
	T = int(input())
	for t in range(T):
		(A, B) = input().split()
		(a, b) = (int(A), int(B))
		rootA = math.sqrt(a)
		rootB = math.sqrt(b)
		num = math.floor(rootB) - math.floor(rootA)
		if rootA == math.floor(rootA):
			num += 1
		print(str(num))
main()


from math import *
for case in range(int(input())):
	(a, b) = map(int, input().split())
	print(int(floor(sqrt(b)) - ceil(sqrt(a)) + 1))


import math
t = int(input())
for x in range(t):
	(a, b) = map(int, input().split())
	aa = int(math.sqrt(a))
	bb = int(math.sqrt(b))
	if aa * aa == a:
		aa -= 1
	print(abs(aa - bb))


def main():
	lis = input().split(' ')
	a = int(lis[0]) - 1
	b = int(lis[1])
	b1 = int(b ** 0.5)
	a1 = int(a ** 0.5)
	print(b1 - a1)
t = int(input())
for n in range(t):
	main()


def main():
	test = int(input(''))
	for i in range(test):
		list = []
		list = input('').split()
		a = int(list[0])
		b = int(list[1])
		count = 0
		for i in range(b):
			if i * i <= b and i * i >= a:
				count = count + 1
			if i * i > b:
				break
		print(count)
main()


inputs = int(input())
from math import ceil, floor, sqrt
for _ in range(inputs):
	(a, b) = [int(x) for x in input().split(' ')]
	a = int(ceil(sqrt(a)))
	b = int(floor(sqrt(b)))
	print(b - a + 1)


import math
t = int(input())
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	n = 0
	s = math.ceil(math.sqrt(a))
	while s * s <= b:
		s += 1
		n += 1
	print(n)


import bisect

def between(L, R, X):
	Li = bisect.bisect_left(X, L)
	Ri = bisect.bisect_left(X, R)
	if X[Ri] == R:
		Ri += 1
	return Ri - Li
sqs = [i ** 2 for i in range(32000)]
for _ in range(int(input())):
	(A, B) = [int(e) for e in input().strip().split()]
	print(between(A, B, sqs))


for i in range(int(input())):
	(a, b) = list(map(int, input().split()))
	a_ = int(a ** 0.5)
	b_ = int(b ** 0.5)
	ans = b_ - a_ + 1
	if a ** 0.5 % 1 != 0:
		ans -= 1
	print(ans)