#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
bool sieve[N];
int main() {
  vector<int> prime;
  for (int i = 2; i < N; i++)
    if (!sieve[i]) {
      prime.push_back(i);
      for (int j = 2 * i; j < N; j += i) sieve[j] = true;
    }
  int t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    bool ok = (a - b) == 1;
    long long x = a + b;
    for (auto p : prime)
      if (x % p == 0 and x != p) ok = false;
    cout << (ok ? "YES" : "NO") << endl;
  }
}
