#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	freopen("factory.in", "r", stdin);
	freopen("factory.out", "w", stdout);
	int t, b, a;
	scanf("%d", &t);
	while (t--)
	{
        scanf("%d%d", &a, &b);
		printf((__builtin_popcount((a + b) / __gcd(a, b)) == 1) ? "YES\n" : "NO\n");
	}	
}