#!/usr/bin/env python
# -*- coding: utf-8 -*-
#  Dan Gau
#  john.py
#  

# Open file, read number of cases.
fin = open("john.in", "r")
numCases = int(fin.readline())

# Go through each case.
for i in range(numCases):
	
	case = fin.readline().split()
	case[0] = int(case[0])
	case[1] = int(case[1])
	hits = 0

	# Keep on going until Johnny is a square.
	# Notice that he can only take a hit if after it his health is
	# above 0.
	while case[1] - case[0] > 0:
		hits += 1
		case[1] -= case[0]
		case[0] += 3
		
	print(hits)

# Close the file!
fin.close()
