import math
def makePrime(n):
while True:
if n % 2 == 0 or n <= 1:
n += 1
continue
sqr = int(math.sqrt(n)) + 1
for divisor in range(3, sqr, 2):
if n % divisor == 0:
n += 1
continue
print(n - totalPlanted)
break
#Driver Code
for i in range(int(input())):
field_1,field_2 = map(int,input().split())
totalPlanted = field_1 + field_2
luckyNo = totalPlanted + 1
makePrime(luckyNo)
link to problem : POTATOES Problem - CodeChef