#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n = 0, x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0;
  int t = 0, check = 0, chet = 0;
  int a[10];
  cin >> t;
  for (int d = 0; d < t; d++) {
    cin >> x1 >> y1;
    if (x1 > y1) {
      x2 = x1;
      y2 = y1;
    } else {
      x2 = y1;
      y2 = x1;
    }
    if (x2 - y2 > 1) {
      a[chet] = -1;
      chet++;
    } else {
      n = x2 + y2;
      for (long long i = 2; i <= sqrt(n); i++) {
        if (n % i == 0) {
          check = -1;
        }
      }
      if (check == -1) {
        a[chet] = -1;
        chet++;
      } else {
        a[chet] = 1;
        chet++;
      }
      check = 0;
    }
  }
  for (int d = 0; d < t; d++) {
    if (a[d] == 1) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}
