#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b;
  int t;
  cin >> t;
  vector<int> vec(100001);
  vec[0] = 2;
  for (int i = 1; i < 100001; ++i) {
    vec[i] = vec[i - 1] * vec[i - 1];
  }
  while (t--) {
    cin >> a >> b;
    if (a - b > 1) {
      cout << "NO\n";
    } else {
      bool ind = 1;
      for (long long i = 2; i <= sqrt(b + a); ++i) {
        if ((a + b) % i == 0) {
          cout << "NO\n";
          ind = 0;
          break;
        }
      }
      if (ind) {
        cout << "YES\n";
      }
    }
  }
  return 0;
}
