Case = input()

x_to_y = [list(map(int, input().split(' '))) for _ in range(int(Case))]

def work(sp, ep):
    dist = ep - sp
    
    if(dist == 1):
        return 1
    elif(dist == 2):
        return 2
    
    n = 1
    
    while(True):
        if((dist >= (n ** 2 - n + 1)) & (dist <= n ** 2)):
            return n * 2 - 1
        elif((dist > n**2) & (dist <= (n ** 2 + n))):
            return n * 2
        
        n += 1
        
for a, b in x_to_y:
    print(work(a, b))

 

'# 코딩 문제 관련 > 파이썬' 카테고리의 다른 글

백준 2775번(python)  (0) 2019.05.27
백준 10250번(python)  (0) 2019.05.27
Baekjoon 1193번(python)  (0) 2019.05.01
Baekjoon 2292번(python)  (0) 2019.04.29
Baekjoon 2941번(python)  (0) 2019.04.29