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