#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> a >> b;
    if (a - b != 1) {
      cout << "NO\n";
      continue;
    }
    bool control = true;
    for (long long i = 2; i * i <= a + b; i++) {
      if ((a + b) % i == 0) {
        cout << "NO\n";
        control = false;
        break;
      }
    }
    if (control) cout << "YES\n";
  }
  return 0;
}
