#include <cstdio> int amicable(int n) { int sum = 0; for(int i = 1; i < n; ++ i) if(n % i == 0) sum += i; return sum; } int main() { int n, a, b, p, q; scanf("%d", &n); while(n --) { scanf("%d %d", &a, &b); p = amicable(a); q = amicable(b); if(p == b && q == a) printf("YES "); else printf("NO "); } return 0; }