#include <fstream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	ifstream cin("factory.in");
	ofstream cout("factory.out");
	int t;
	cin >> t;
	while (t--)
	{
		long long a, b;
		cin >> a >> b;
		cout << ((__builtin_popcountll((a + b) / __gcd(a, b)) == 1) ? "YES\n" : "NO\n");
	}	
}