#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout.precision(20);
  long long int tt;
  cin >> tt;
  while (tt--) {
    long long int a, b;
    cin >> a >> b;
    if ((a - b) != 1) {
      cout << "NO" << endl;
      continue;
    }
    long long int flag = 1;
    for (auto i = 2; i <= 1000000; i++) {
      if ((a + b) % i == 0) {
        flag = 0;
        break;
      }
      if (i * i > (a + b)) {
        break;
      }
    }
    if (flag)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  };
  return 0;
}
