Exceptions

Errors detected during execution are called exceptions.

Examples:

ZeroDivisionError 

This error is raised when the second argument of a division or modulo operation is zero.

>>> a = '1'
>>> b = '0'
>>> print int(a) / int(b)
>>> ZeroDivisionError: integer division or modulo by zero

ValueError 

This error is raised when a built-in operation or function receives an argument that has the right type but an inappropriate value. 

>>> a = '1'
>>> b = '#'
>>> print int(a) / int(b)
>>> ValueError: invalid literal for int() with base 10: '#'

 To learn more about different built-in exceptions click here.    

Handling Exceptions

The statements try and except can be used to handle selected exceptions. A try statement may have more than one except clause to specify handlers for different exceptions.

#Code
try:
    print 1/0
except ZeroDivisionError as e:
    print "Error Code:",e

Output

Error Code: integer division or modulo by zero

Task

You are given two values $\boldsymbol{\alpha}$ and $\boldsymbol{b}$. 

Perform integer division and print $a/b$. 

Input Format

The first line contains $\mathbf{T}$, the number of test cases. 

The next $\mathbf{T}$ lines each contain the space separated values of $\boldsymbol{\alpha}$ and $\boldsymbol{b}$.

Constraints

$0<T<10$

Output Format

Print the value of $a/b$. 

In the case of ZeroDivisionError or ValueError, print the error code.

Sample Input
3
1 0
2 $
3 1

Sample Output
Error Code: integer division or modulo by zero
Error Code: invalid literal for int() with base 10: '$'
3

 Note: 

For integer division in Python 3 use //.

Source: hackerrank | Difficulty: EASY


Solutions:
N = int(input())
for _ in range(N):
	try:
		(a, b) = map(int, input().split())
		print(a // b)
	except (ZeroDivisionError, ValueError) as e:
		print('Error Code:', e)


n = int(input())
for i in range(0, n):
	(x, y) = input().split()
	try:
		print(int(x) // int(y))
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)


n = int(input())
for _ in range(n):
	try:
		(a, b) = [int(el) for el in input().split()]
		print(a // b)
	except Exception as exc:
		print('Error Code: %s' % exc)


lines = int(input())
for i in range(lines):
	(a, b) = input().split()
	try:
		val = int(a) // int(b)
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)
	else:
		print(val)


def DivisionTest(data):
	try:
		(a, b) = map(int, data.split())
		return a // b
	except (ZeroDivisionError, ValueError) as e:
		return 'Error Code: %s' % e
for _ in range(int(input())):
	print(DivisionTest(input()))


n = int(input())
for i in range(n):
	try:
		(a, b) = map(int, input().split())
	except ValueError as e:
		print('Error Code:', e)
		continue
	try:
		print(a // b)
	except ZeroDivisionError as e:
		print('Error Code:', e)


def compute(x, y):
	try:
		print(int(x) // int(y))
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)
	except Error as e:
		print('Error Code:', e)
import sys
state = 0
num_tests = 0
counter = 0
arr = []
for line in sys.stdin:
	if state == 0:
		num_tests = int(line.strip())
		state = 1
	elif state == 1:
		arr.append([e for e in line.strip().split(' ')])
		counter += 1
		if counter == num_tests:
			for (x, y) in arr:
				compute(x, y)
			state = 0
			counter = 0


N = [input() for _ in range(int(input()))]
for each in N:
	this = each.split()
	try:
		print(int(this[0]) // int(this[1]))
	except Exception as e:
		print('Error Code:', e)


t = int(input())
for i in range(0, t):
	values = input().split()
	a = -1
	b = -1
	try:
		a = int(values[0])
		b = int(values[1])
	except ValueError as ex:
		print('Error Code:', ex)
		continue
	try:
		print(int(a / b))
	except (ZeroDivisionError, ValueError) as ex:
		print('Error Code: integer division or modulo by zero')


for i in range(int(input())):
	(a, b) = input().split()
	try:
		print(int(a) // int(b))
	except ZeroDivisionError as e:
		print('Error Code: integer division or modulo by zero')
	except ValueError as e:
		print('Error Code:', e)


num = int(input())
for n in range(num):
	(a, b) = input().strip().split()
	try:
		a = int(a)
		b = int(b)
		print(a // b)
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)


n = int(input())
for i in range(n):
	(a1, b1) = input().split()
	try:
		a = int(a1)
		b = int(b1)
		print(a // b)
	except ValueError as v:
		print('Error Code:', v)
	except ZeroDivisionError as z:
		print('Error Code:', z)


for i in range(int(input())):
	(a, b) = input().split()
	try:
		print(int(a) // int(b))
	except ZeroDivisionError as z:
		print('Error Code:', z)
	except ValueError as v:
		print('Error Code:', v)


t = int(input())
for i in range(t):
	(a, b) = input().split()
	try:
		print(int(a) // int(b))
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)


t = int(input())
for _ in range(t):
	try:
		(a, b) = [int(i) for i in input().split()]
		print(int(a) // int(b))
	except Exception as e:
		print('Error Code:', e)


t = int(input())
list = []
for i in range(t):
	in1 = input().split()
	list.append(in1)
for i in range(len(list)):
	try:
		print(int(list[i][0]) // int(list[i][1]))
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)


n = int(input().strip())
for i in range(n):
	(x, y) = input().split()
	try:
		print(int(x) // int(y))
	except (ZeroDivisionError, ValueError) as error:
		print('Error Code:', error)


t = int(input())
for i in range(t):
	(a, b) = input().split()
	try:
		a = int(a)
		b = int(b)
		print(int(a // b))
	except Exception as e:
		print('Error Code:' + ' ' + str(e))


n = int(input())
for i in range(n):
	try:
		values = list(map(int, input().split()))
		print(values[0] // values[1])
	except ZeroDivisionError as a:
		print('Error Code:', a)
	except ValueError as a:
		print('Error Code:', a)


n = int(input())
for i in range(n):
	(a, b) = input().split()
	try:
		a = int(a)
		b = int(b)
		print(a // b)
	except Exception as e:
		print('Error Code:', e)


n = int(input())
for i in range(n):
	(a, b) = input().split()
	try:
		print(int(a) // int(b))
	except Exception as e:
		print('Error Code: ' + str(e))


T = int(input(''))
for i in range(T):
	numbers = input('')
	numbersList = numbers.split()
	a = numbersList[0]
	b = numbersList[1]
	try:
		print(int(a) // int(b))
	except ValueError as e:
		print('Error Code:', e)
	except ZeroDivisionError as e:
		print('Error Code:', e)


t = input()
for x in range(0, int(t)):
	try:
		(a, b) = input().split()
		a = int(a)
		b = int(b)
		print(a // b)
	except (ZeroDivisionError, ValueError) as e:
		print('Error Code:', e)


t = int(input())
while t > 0:
	l = input()
	try:
		s = int(l[0]) // int(l[2])
		print(s)
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)
	t -= 1


T = int(input())
for test_case in range(0, T):
	try:
		(a, b) = map(int, input().split())
		print(a // b)
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)


n = int(input())
for _ in range(n):
	try:
		inp = [int(x) for x in input().split()]
		print(inp[0] // inp[1])
	except Exception as e:
		print('Error Code:', e)


N = int(input())
for i in range(N):
	L = input().split()
	try:
		print(int(L[0]) // int(L[1]))
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except BaseException as b:
		print('Error Code:', b)


t = int(input())
for _ in range(t):
	try:
		(a, b) = map(int, input().split())
		print(a // b)
	except (ZeroDivisionError, ValueError) as e:
		print('Error Code:', e)
	except ValueError as f:
		print('Error Code:', e)


nb = int(input())
for _ in range(nb):
	(a, b) = input().split()
	try:
		print(int(a) // int(b))
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)


n = int(input())
for _ in range(0, n):
	try:
		(a, b) = str(input()).split(' ')
		if b == '$\r':
			b = '$'
		print(int(a) // int(b))
	except (ZeroDivisionError, ValueError) as exc:
		print('Error Code: %s' % exc)
	except Exception as exc:
		pass


for _ in range(int(input())):
	(a, b) = input().split()
	try:
		print(int(a) // int(b))
	except Exception as e:
		print('Error Code:', e)


t = int(input())
for i in range(t):
	try:
		(a, b) = map(int, input().split())
		print(a // b)
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as f:
		print('Error Code:', f)


N = int(input())
for _ in range(N):
	(a, b) = input().split()
	try:
		print(int(a) // int(b))
	except (ZeroDivisionError, ValueError) as e:
		print('Error Code:', e)


ints = lambda : list(map(int, input().split()))
error = lambda e: print('Error Code: {}'.format(e))
for _ in range(ints()[0]):
	try:
		(a, b) = ints()
		print(a // b)
	except ValueError as e:
		error(e)
	except ZeroDivisionError as e:
		error(e)


t = int(input())
for _ in range(t):
	(a, b) = input().split()
	try:
		div = int(a) // int(b)
		print(div)
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)


I = [input().split() for _ in range(int(input()))]
for x in I:
	try:
		print(int(x[0]) // int(x[1]))
	except (ZeroDivisionError, ValueError) as e:
		print('Error Code:', e)


t = int(input())
for i in range(0, t):
	line = input().split()
	a = line[0]
	b = line[1]
	try:
		print(int(a) // int(b))
	except ZeroDivisionError as e:
		print('Error Code: integer division or modulo by zero')
	except ValueError as e:
		print('Error Code:', e)


for _ in range(int(input())):
	try:
		(a, b) = map(int, input().split())
		print(a // b)
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)


lines = int(input())
for _ in range(lines):
	(a, b) = input().split()
	try:
		print(int(a) // int(b))
	except (ZeroDivisionError, ValueError) as e:
		print('Error Code:', e)


for _ in range(int(input().strip())):
	try:
		(a, b) = map(int, input().strip().split())
		print(a // b)
	except Exception as e:
		print('Error Code: {}'.format(e))


T = int(input())
for x in range(T):
	(a, b) = input().split()
	try:
		print(int(a) // int(b))
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)


a = int(input())
d = 0
g = 1
for i in range(0, a):
	b = input().split(' ')
	try:
		if b[0] == '#' or b[0] == '*' or b[0] == '%' or (b[0] == '&') or (b[0] == '$'):
			g = 0
		c = int(b[0]) / int(b[1])
		d = 1
	except ZeroDivisionError as e:
		print('Error Code: integer division or modulo by zero')
	except ValueError as e:
		if b[0] == '#' or b[1] == '#':
			print("Error Code: invalid literal for int() with base 10: '#'")
		else:
			print("Error Code: invalid literal for int() with base 10: '$'")
	if d == 1:
		print(int(c))


for _ in range(int(input())):
	try:
		(a, b) = map(int, input().split())
		print(a // b)
	except ZeroDivisionError as e:
		print('Error Code: ' + str(e))
	except ValueError as e:
		print('Error Code: ' + str(e))


n = int(input())
while n > 0:
	try:
		s = input()
		s = s.split()
		try:
			x = int(s[0])
			y = int(s[1])
			print(x // y)
		except ValueError as e:
			print('Error Code:', e)
	except ZeroDivisionError as e:
		print('Error Code:', e)
	n -= 1


N = int(input())
for _ in range(N):
	nums = input().replace('\r', '').split(' ')
	try:
		print(int(nums[0]) // int(nums[1]))
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)


n = int(input())
for _ in range(n):
	try:
		nums = [int(x) for x in input().split()]
	except ValueError as e:
		print('Error Code:', e)
		continue
	try:
		x = nums[0] / nums[1]
		print(int(x))
	except ZeroDivisionError as t:
		print('Error Code:', 'integer division or modulo by zero')
		continue


def __starting_point():
	t = int(input().strip())
	for _ in range(t):
		(a, b) = input().strip().split(' ')
		try:
			print(int(a) // int(b))
		except ZeroDivisionError as e:
			print('Error Code: {}'.format(e))
		except ValueError as e:
			print('Error Code: {}'.format(e))
__starting_point()


n = int(input())
for _ in range(n):
	try:
		(a, b) = map(int, input().split())
		print(a // b)
	except (ZeroDivisionError, ValueError, TypeError) as e:
		print('Error Code:', e)


for _ in range(int(input())):
	try:
		(a, b) = list(map(int, input().split()))
		print(int(a / b))
	except ZeroDivisionError as e:
		print('Error Code: integer division or modulo by zero')
	except ValueError as b:
		print('Error Code: ' + str(b))


import sys
if sys.version_info[0] >= 3:
	raw_input = input
for i in range(int(raw_input())):
	try:
		(x, y) = map(int, raw_input().split())
		print(x // y)
	except ValueError as e:
		print('Error Code: ' + str(e))
	except ZeroDivisionError as e:
		print('Error Code: ' + str(e))


for i in range(0, int(input())):
	try:
		(a, b) = map(int, input().split())
		print(a // b)
	except ZeroDivisionError as w:
		print('Error Code:', w)
	except ValueError as e:
		print('Error Code:', e)


n_tests = int(input())
for t in range(n_tests):
	try:
		(a, b) = map(int, input().split())
	except ValueError as e:
		print('Error Code:', e)
		continue
	try:
		c = a // b
	except ZeroDivisionError as e:
		print('Error Code:', e)
		continue
	print(c)


for _ in range(int(input())):
	try:
		(a, b) = map(int, input().strip().split())
		print(a // b)
	except Exception as e:
		print('Error Code:', e)


T = int(input())
for i in range(0, T):
	Line = str(input()).split()
	try:
		print(int(Line[0]) // int(Line[1]))
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)


cases = int(input())
for case in range(cases):
	(a_str, b_str) = input().split()
	try:
		print(int(a_str) // int(b_str))
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)


t = int(input())
for _ in range(t):
	(a, b) = input().split()
	try:
		print(int(a) // int(b))
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)


for i in range(int(input())):
	(a, b) = input().split()
	try:
		print(int(a) // int(b))
	except (ZeroDivisionError, ValueError) as e:
		print('Error Code:', e)


for _ in range(int(input())):
	(a1, a2) = input().split()
	try:
		print(int(a1) // int(a2))
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)


c = int(input())
for i in range(c):
	try:
		(a, b) = list(map(int, input().split()))
		print(a // b)
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)


count = int(input())
for i in range(count):
	(a, b) = input().split()
	try:
		print(int(a) // int(b))
	except ValueError as e:
		print('Error Code:', e)
	except ZeroDivisionError as e:
		print('Error Code:', e)


def main():
	numLines = int(input())
	numbers = []
	for _ in range(numLines):
		(a, b) = input().split()
		numbers.append((a, b))
	for testnumber in numbers:
		try:
			div = int(testnumber[0]) / int(testnumber[1])
			print(int(div))
		except ZeroDivisionError as e:
			print('Error Code: integer division or modulo by zero')
		except ValueError as e:
			print('Error Code:', e)
main()


for i in range(int(input())):
	try:
		try:
			(a, b) = map(int, input().split())
			print(a // b)
		except ZeroDivisionError as e:
			print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)


n = int(input().strip())
for i in range(n):
	(x, y) = input().strip().split()
	try:
		print(str(int(int(x) / int(y))))
	except ValueError as e:
		print('Error Code:', e)
	except ZeroDivisionError as e:
		print('Error Code: integer division or modulo by zero')


t = int(input())
for i in range(t):
	try:
		(a, b) = map(int, input().split())
		print(a // b)
	except Exception as e:
		print('Error Code: %s' % e)


n = int(input())
for _ in range(n):
	try:
		(a, b) = input().split()
		print(int(a) // int(b))
	except ZeroDivisionError as e:
		print('Error Code: integer division or modulo by zero')
	except ValueError as e:
		print('Error Code:', e)


I = int(input())
N = [input().split() for i in range(I)]
for x in N:
	try:
		print(int(x[0]) // int(x[1]))
	except (ZeroDivisionError, ValueError) as e:
		print('Error Code:', e)


N = int(input())
for i in range(N):
	try:
		(a, b) = map(int, input().split())
		print(a // b)
	except ValueError as e:
		print('Error Code:', e)
	except ZeroDivisionError as e:
		print('Error Code:', e)


x = int(input())
for i in range(x):
	(a, b) = input().split()
	try:
		print(int(a) // int(b))
	except Exception as e:
		print('Error Code:', e)


n = int(input())
for _ in range(n):
	(a, b) = input().split()
	try:
		print(int(a) // int(b))
	except (ZeroDivisionError, ValueError) as e:
		print('Error Code:', e)


T = int(input())
for t in range(T):
	try:
		(a, b) = map(int, input().split())
	except ValueError as err:
		print('Error Code:', err)
		continue
	try:
		print(int(a / b))
	except ZeroDivisionError as err:
		print('Error Code: integer division or modulo by zero')


for _ in range(int(input())):
	(a, b) = input().split()
	try:
		print(int(a) // int(b))
	except (ZeroDivisionError, ValueError) as e:
		print('Error Code:', e)


in1 = int(input(''))
while in1 > 0:
	result = 0
	try:
		str1 = list(map(int, input('').strip().split(' ')))
		result = str1[0] // str1[1]
		print(result)
	except ValueError as e:
		print('Error Code:', e)
	except ZeroDivisionError as e:
		print('Error Code:', e)
	in1 -= 1


t = [list(input().split()) for x in range(int(input()))]
for (j, i) in t:
	try:
		print(int(j) // int(i))
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)


T = int(input())
for i in range(T):
	lis = input().split()
	try:
		print(int(lis[0]) // int(lis[1]))
	except ZeroDivisionError as e:
		print('Error Code: ' + str(e))
	except ValueError as e:
		print('Error Code: ' + str(e))


t = int(input())
for _ in range(t):
	try:
		(a, b) = map(int, input().split())
		print(a // b)
	except ZeroDivisionError as e:
		print('Error Code: ' + str(e))
	except ValueError as e:
		print('Error Code: ' + str(e))


n = int(input())
for i in range(n):
	try:
		ab = list(map(int, input().split()))
		print(int(ab[0] / ab[1]))
	except ValueError as e:
		print('Error Code:', e)
	except ZeroDivisionError as e:
		print('Error Code: integer division or modulo by zero')


b = int(input())
a = [input().split() for i in range(b)]
for i in range(b):
	try:
		print(int(a[i][0]) // int(a[i][1]))
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as r:
		print('Error Code:', r)


n = input()
while True:
	try:
		try:
			(a, b) = map(int, input().split())
			try:
				ans = a // b
				print(ans)
			except ZeroDivisionError as e:
				print('Error Code:', e)
		except ValueError as f:
			print('Error Code:', f)
	except EOFError:
		break


T = int(input())
for i in range(T):
	(a, b) = input().split()
	if b == '0':
		try:
			print(int(a) // int(b))
		except ZeroDivisionError as e:
			print('Error Code:', e)
	elif b != 0:
		try:
			print(int(a) // int(b))
		except ValueError as e:
			print('Error Code:', e)
	else:
		print(int(a) // int(b))


for i in range(int(input())):
	L = list(input().split())
	try:
		print(int(int(L[0]) / int(L[1])))
	except ZeroDivisionError as e:
		print('Error Code:', 'integer division or modulo by zero')
	except ValueError as d:
		print('Error Code:', d)


numberOfTestCases = int(input())
while numberOfTestCases > 0:
	elements = input().split()
	try:
		firstItem = int(elements[0])
		secondItem = int(elements[1])
		print(firstItem // secondItem)
	except ValueError as v:
		print('Error Code:', v)
	except ZeroDivisionError as z:
		print('Error Code:', z)
	numberOfTestCases -= 1


T = int(input())
while T > 0:
	try:
		(a, b) = map(int, input().split())
		print(a // b)
	except (ZeroDivisionError, ValueError) as e:
		print('Error Code:', e)
	T -= 1


n = int(input())
arr = []
for i in range(0, n):
	arr.append(input().split())
for i in range(0, n):
	try:
		print(int(arr[i][0]) // int(arr[i][1]))
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)


for _ in range(int(input())):
	try:
		numbers = [int(x) for x in input().split()]
		print(numbers[0] // numbers[1])
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)


n = int(input())
for _ in range(n):
	try:
		(a, b) = map(int, input().split())
		print(a // b)
	except ValueError as es:
		print('Error Code:', es)
	except ZeroDivisionError as e:
		print('Error Code:', e)


t = int(input())
for i in range(t):
	(a, b) = input().split()
	try:
		print(int(a) // int(b))
	except (ZeroDivisionError, ValueError) as e:
		print('Error Code: {0}'.format(e))


for i in range(int(input())):
	try:
		(a, b) = list(map(int, input().split()))
		print(a // b)
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)


n = int(input())
for _ in range(n):
	try:
		(a, b) = map(int, input().split())
		print(int(a / b))
	except ZeroDivisionError as e:
		print('Error Code:' + ' integer division or modulo by zero')
	except ValueError as ve:
		print('Error Code:', ve)


t = int(input())
for _ in range(t):
	try:
		(a, b) = [int(x) for x in input().split()]
		print(a // b)
	except ValueError as e:
		print('Error Code: %s' % e)
	except ZeroDivisionError as e:
		print('Error Code: %s' % e)


N = int(input())
for i in range(N):
	try:
		(a, b) = map(int, input().split())
		ans = a // b
	except ZeroDivisionError as e:
		print('Error Code: integer division or modulo by zero')
	except ValueError as v:
		print('Error Code: {}'.format(v))
	else:
		print(ans)


T = int(input())
for i in range(T):
	(a, b) = input().split()
	try:
		print(int(a) // int(b))
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)


count = int(input())
for i in range(count):
	try:
		(first, second) = [int(i) for i in input().split()]
	except ValueError as e:
		print('Error Code: {}'.format(e))
	else:
		try:
			a = first // second
		except ZeroDivisionError as e:
			print('Error Code: {}'.format(e))
		else:
			print(a)


t = int(input())
for i in range(t):
	try:
		(a, b) = map(int, input().split())
	except ValueError as e:
		print('Error Code:', e)
		continue
	try:
		print(a // b)
	except ZeroDivisionError as e:
		print('Error Code:', e)


__author__ = 'namii'
T = int(input())
for _ in range(T):
	contents = input().split()
	try:
		print(int(contents[0]) // int(contents[1]))
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)


num_of_testcases = int(input())
for i in range(0, num_of_testcases):
	testcase = list(input().strip().split(' '))
	a = testcase[0]
	b = testcase[1]
	print
	try:
		print(int(a) // int(b))
	except (ZeroDivisionError, ValueError) as e:
		print('Error Code:', e)


N = int(input())
for i in range(0, N):
	arr = input().split()
	try:
		a = int(arr[0])
		b = int(arr[1])
		print(a // b)
	except ZeroDivisionError as e:
		print('Error Code:', e)
	except ValueError as e:
		print('Error Code:', e)