#include <bits/stdc++.h>
using namespace std;
bool check(long long y) {
  for (long long x = 2; x * x <= y; x++) {
    if (y % x == 0) return 0;
  }
  return 1;
}
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  long long n, x, y;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> y >> x;
    if (y - x == 1 && check(x + y)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}
