Assume the cricket ground to be an infinite grid and there can be more than 11 players in a team. It is known that the batsmen stand at the point (0,0). The field placement follows the following pattern

1st fielder is to be placed at 1 step to the east of batsman.
2nd fielder is to be placed at 2 steps to the north of 1st fielder
3rd fielder is to be placed at 3 steps to the West of 2nd fielder
4th fielder is to be placed at 4 steps to the south of 3rd fielder
5th fielder is to be placed at 5 steps to the East of 4th fielder
6th fielder is to be placed at 6 steps to the North of 5th fielder  

And so on….

The fielders can be placed at only these positions and no where else…i.e at (1,0) , (1,2) , ( -2,2) ,  (-2,-2) and so on.

In the CWC final 2015, Michael Clarke realizes that to win the match, it is crucial to get Brendon McCullum out early . After a deep study, it was found that Brendon often gets out by giving catch to fielders standing at prime numbered positive positions of x on X-Y plane on the grid . He has decided that he will himself take the catch. Now, Clarke is confused and wants your help to win the match. Find out for him whether Clarke has positioned himself at any of the catching positions or not.
Input :
Input starts with T denoting the number of test cases.
Next T lines contains space separated coordinates x,y which are coordinates of point where Clarke has positioned himself.

Output :
If the position is wicket taking , then print “YES” without quotes else Print “NO”.

Constraints :
1 ≤ T ≤ 100
1 ≤ x,y ≤ 10^5

Problem Setter : Adesh Kala

SAMPLE INPUT
4
3 3
3 4
5 5
6 6

SAMPLE OUTPUT
NO
YES
NO
NO
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
# your code goes here
import math
def isprime(a):
	n=int(math.ceil(math.sqrt(a)))
	if a==2 or a==3 :
	    return True
	if a==1:
		return False
	else:
	    for i in range(2,n+1):
		    if a%i==0:
			    return False
	return True
n=int(raw_input())
for i in range(n):
	a,b=map(int,raw_input().split())
	if a>0 and a%2==1:
		if isprime(a) and (b==a+1) : 
			print("YES")
		else:
			print("NO")
	else:
		print("NO")