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