#include <bits/stdc++.h>
using namespace std;
bool prime(long long x) {
  for (long long i = 2; i * i <= x; i++)
    if (x % i == 0) return 0;
  return 1;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    long long x = a - b, y = a + b;
    if (x == 1 && prime(y))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
