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