#include <bits/stdc++.h>
using namespace std;
bool isPrime(long long x) {
  for (long long i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int n;
  long long a, b;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a >> b;
    if ((a - b) == 1 && isPrime(a + b))
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
