#include <bits/stdc++.h>
using namespace std;
long long n, i, j, m, k, t, sum = 0, cnt = 0, a, b, d, rem, mod, mx, mn;
string s, s1;
map<long long, long long> make_pair;
map<long long, long long>::iterator it;
vector<pair<long long, long long> > v;
vector<long long> v1, v2, v3;
vector<long long> v4[51];
bool check(long long k) {
  for (i = 2; i <= sqrt(k); i++)
    if (k % i == 0) return false;
}
int main() {
  cin >> t;
  while (t--) {
    cin >> a >> b;
    if (a - b == 1) {
      k = (a - b) * (a + b);
      bool ck = check(k);
      if (ck == false)
        cout << "NO" << endl;
      else
        cout << "YES" << endl;
    } else
      cout << "NO" << endl;
  }
}
