#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
using namespace std;
int n,a,b;
bool isp[31630];
vector<int> prime;
const int rt=31625;
int main(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        for(int i=2;i<=rt;i++){
                if(isp[i])continue;
                prime.push_back(i);
                if(1ll*i*i>rt)break;
                for(int j=i*i;j<=rt;j+=i){
                        isp[j]=true;
                }
        }
        cin>>n;
        while(n--){
                cin>>a>>b;
                long long t=1ll*a*b;
                bool frog=true;
                for(int i=0;i<prime.size();i++){
                        int md=prime[i],cnt=0;
                        while(t%md==0){
                                t/=md;
                                cnt++;
                        }
                        if(cnt%3){
                                cout<<"No\n";
                                frog=false;
                                break;
                        }
                }
                if(frog){
                        if(t==1)cout<<"Yes\n";
                        else cout<<"No\n";
                }
        }
        return 0;
}


#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
using namespace std;
int n,a,b;
bitset<500000005> isp;
vector<int> prime;
const int rt=31625;
int main(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        for(int i=2;i<=500000000;i++){
                if(isp[i])continue;
                if(i<rt)prime.push_back(i);
                if(1ll*i*i>500000000)continue;
                for(int j=i*i;j<=500000000;j+=i){
                        isp[j]=true;
                }
        }
        cin>>n;
        while(n--){
                cin>>a>>b;
                int ta=a,tb=b;
                bool frog=true;
                for(int i=0;i<prime.size() && ta>1 && tb>1;i++){
                        if(ta>rt && ta<500000000 && !isp[ta])break;
                        if(tb>rt && tb<500000000 && !isp[tb])break;
                        int md=prime[i],ca=0,cb=0;
                        while(ta%md==0){
                                ta/=md;
                                ca++;
                        }
                        while(tb%md==0){
                                tb/=md;
                                cb++;
                        }
                        if((ca+cb)%3){
                                frog=false;
                                break;
                        }
                        int c=(ca+cb)/3,d=ca-cb;
                        if((c+d)&1 || c-d<0 || c+d<0){
                                frog=false;
                                break;
                        }
                }
                if(frog){
                        if(ta==1 && tb==1)cout<<"Yes\n";
                        else cout<<"No\n";
                }
                else cout<<"No\n";
        }
        return 0;
}


#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
using namespace std;
int n,a,b;
vector<pair<int,int> > fa;
int main(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        cin>>n;
        while(n--){
                cin>>a>>b;
                fa.clear();
                int ta=a,tb=b;
                for(int i=2;i*i<=a;i++){
                        if(ta%i==0){
                                int cnt=0;
                                while(ta%i==0){
                                        ta/=i;
                                        cnt++;
                                }
                                fa.push_back(make_pair(i,cnt));
                        }
                }
                if(ta>1)fa.push_back(make_pair(ta,1));
                bool frog=true;
                for(int i=0;i<fa.size();i++){
                        int u=fa[i].first;
                        int cnt=0;
                        while(tb%u==0){
                                tb/=u;
                                cnt++;
                        }
                        int ca=fa[i].second,cb=cnt;
                        while(ca && cb){
                                if(ca>cb){
                                        ca-=2;
                                        cb--;
                                }
                                else{
                                        ca--;
                                        cb-=2;
                                }
                        }
                        if(ca || cb){
                                cout<<"No\n";
                                frog=false;
                                break;
                        }
                }
                if(frog){
                        if(!tb)cout<<"Yes\n";
                        else cout<<"No\n";
                }
        }
        return 0;
}


#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
using namespace std;
int n,a,b;
bitset<100000005> isp;
vector<int> prime;
const int rt=31625;
int main(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        for(int i=2;i<=100000000;i++){
                if(isp[i])continue;
                if(i<rt)prime.push_back(i);
                if(1ll*i*i>100000000)continue;
                for(int j=i*i;j<=rt;j+=i){
                        isp[j]=true;
                }
        }
        cin>>n;
        while(n--){
                cin>>a>>b;
                int ta=a,tb=b;
                bool frog=true;
                for(int i=0;i<prime.size() && ta>1 && tb>1;i++){
                        if(ta>rt && ta<100000000 && !isp[ta])break;
                        if(tb>rt && tb<100000000 && !isp[tb])break;
                        int md=prime[i],ca=0,cb=0;
                        while(ta%md==0){
                                ta/=md;
                                ca++;
                        }
                        while(tb%md==0){
                                tb/=md;
                                cb++;
                        }
                        if((ca+cb)%3){
                                frog=false;
                                break;
                        }
                        int c=(ca+cb)/3,d=ca-cb;
                        if((c+d)&1 || c-d<0 || c+d<0){
                                frog=false;
                                break;
                        }
                }
                if(frog){
                        if(ta==1 && tb==1)cout<<"Yes\n";
                        else cout<<"No\n";
                }
                else cout<<"No\n";
        }
        return 0;
}


#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
using namespace std;
int n,a,b;
bool isp[31630];
vector<int> prime;
const int rt=31625;
int main(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        for(int i=2;i<=rt;i++){
                if(isp[i])continue;
                prime.push_back(i);
                if(1ll*i*i>rt)continue;
                for(int j=i*i;j<=rt;j+=i){
                        isp[j]=true;
                }
        }
        cin>>n;
        while(n--){
                cin>>a>>b;
                int ta=a,tb=b;
                bool frog=true;
                for(int i=0;i<prime.size();i++){
                        int md=prime[i],ca=0,cb=0;
                        while(ta%md==0){
                                ta/=md;
                                ca++;
                        }
                        while(tb%md==0){
                                tb/=md;
                                cb++;
                        }
                        if((ca+cb)%3){
                                frog=false;
                                break;
                        }
                        int c=(ca+cb)/3,d=ca-cb;
                        if((c+d)&1 || c-d<0 || c+d<0){
                                frog=false;
                                break;
                        }
                }
                if(frog){
                        if(ta==1 && tb==1)cout<<"Yes\n";
                        else cout<<"No\n";
                }
                else cout<<"No\n";
        }
        return 0;
}


#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
using namespace std;
int n,a,b;
vector<pair<int,int> > fa;
int main(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        cin>>n;
        while(n--){
                cin>>a>>b;
                fa.clear();
                int ta=a,tb=b;
                for(int i=2;i*i<=a;i++){
                        if(ta%i==0){
                                int cnt=0;
                                while(ta%i==0){
                                        ta/=i;
                                        cnt++;
                                }
                                fa.push_back(make_pair(i,cnt));
                        }
                }
                if(ta>1)fa.push_back(make_pair(ta,1));
                bool frog=true;
                for(int i=0;i<fa.size();i++){
                        int u=fa[i].first;
                        int cnt=0;
                        while(tb%u==0){
                                tb/=u;
                                cnt++;
                        }
                        int ca=fa[i].second,cb=cnt;
                        while(ca && cb){
                                if(ca>cb){
                                        ca-=2;
                                        cb--;
                                }
                                else{
                                        ca--;
                                        cb-=2;
                                }
                        }
                        if(ca || cb){
                                cout<<"No\n";
                                frog=false;
                                break;
                        }
                }
                if(frog){
                        if(tb==1)cout<<"Yes\n";
                        else cout<<"No\n";
                }
        }
        return 0;
}


#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
using namespace std;
int n,a,b;
bool isp[31630];
vector<int> prime;
const int rt=31625;
int main(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        for(int i=2;i<=rt;i++){
                if(isp[i])continue;
                prime.push_back(i);
                if(1ll*i*i>rt)continue;
                for(int j=i*i;j<=rt;j+=i){
                        isp[j]=true;
                }
        }
        cin>>n;
        while(n--){
                cin>>a>>b;
                int ta=a,tb=b;
                bool frog=true;
                for(int i=0;i<prime.size() && ta>1 && tb>1;i++){
                        int md=prime[i],ca=0,cb=0;
                        while(ta%md==0){
                                ta/=md;
                                ca++;
                        }
                        while(tb%md==0){
                                tb/=md;
                                cb++;
                        }
                        if((ca+cb)%3){
                                frog=false;
                                break;
                        }
                        int c=(ca+cb)/3,d=ca-cb;
                        if((c+d)&1 || c-d<0 || c+d<0){
                                frog=false;
                                break;
                        }
                        if(md>1000 && (ca>0 || cb>0))break;
                }
                if(frog){
                        if(ta==1 && tb==1)cout<<"Yes\n";
                        else cout<<"No\n";
                }
                else cout<<"No\n";
        }
        return 0;
}


#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;
typedef long long lld;

const lld N = 2000000;
bool p[N];
int pri[N];
int pcnt = 0;

void pre()
{
	memset(p, true, sizeof(p));
	for(lld i = 2; i < N; i++)
	{
		if( p[i] )
		{
			pri[pcnt++] = i;

			for(lld j = i*i; j < N; j += i)
				p[j] = false;
		}
	}
}

int main()
{
	pre();
	int n;
	scanf("%d", &n);

	for(; n > 0; n--)
	{
		lld a,b;
		scanf("%lld %lld", &a, &b);

		bool ans = true;

		for(int i = 0; i < pcnt; i++)
		{
			int p = 0, q = 0;
			for(; a > 0 && a%pri[i] == 0; a /= pri[i])
				p++;
			for(; b > 0 && b%pri[i] == 0; b /= pri[i])
				q++;

			if( (2*p-q)%3 != 0 || (2*p-q) < 0 )
				ans = false;
			if( (2*q-p)%3 != 0 || (2*q-p) < 0 )
				ans = false;
		}

		puts(ans ? "YES" : "NO");
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;
typedef long long lld;

const lld N = 2000000;
bool p[N];
int pri[N];
int pcnt = 0;

void pre()
{
	memset(p, true, sizeof(p));
	for(lld i = 2; i < N; i++)
	{
		if( p[i] )
		{
			pri[pcnt++] = i;

			for(lld j = i*i; j < N; j += i)
				p[j] = false;
		}
	}
}

int main()
{
	pre();
	int n;
	scanf("%d", &n);

	for(; n > 0; n--)
	{
		lld a,b;
		scanf("%lld %lld", &a, &b);

		bool ans = true;

		for(int i = 0; i < pcnt; i++)
		{
			int p = 0, q = 0;
			for(; a > 0 && a%pri[i] == 0; a /= pri[i])
				p++;
			for(; b > 0 && b%pri[i] == 0; b /= pri[i])
				q++;
			ans &= ((2*p-q)%3 == 0) && ((2*q-p)%3 == 0);
		}

		puts(ans ? "YES" : "NO");
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;
const int N = 1010;
bool p[N];
int pri[N];
int pcnt = 0;

void pre()
{
	memset(p, true, sizeof(p));
	for(int i = 2; i < N; i++)
	{
		if( p[i] )
		{
			pri[pcnt++] = i;

			for(int j = i*i; j < N; j += i)
				p[j] = false;
		}
	}
}

int main()
{
	pre();
	int n;
	scanf("%d", &n);

	for(; n > 0; n--)
	{
		int a,b;
		scanf("%d %d", &a, &b);

		bool ans = true;

		for(int i = 0; ans && i < pcnt; i++)
		{
			int p = 0, q = 0;
			for(; a > 1 && a%pri[i] == 0; a /= pri[i])
				p++;
			for(; b > 1 && b%pri[i] == 0; b /= pri[i])
				q++;

			if( (2*p-q)%3 != 0 || (2*p-q) < 0 )
				ans = false;
			else if( (2*q-p)%3 != 0 || (2*q-p) < 0 )
				ans = false;
		}

		ans &= (b%a == 0 && b/a=a) || (a%b == 0 && a/b=b) || (a == 1 && b == 1);
		puts(ans ? "YES" : "NO");
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;
typedef long long lld;

const lld N = 1010;
bool p[N];
int pri[N];
int pcnt = 0;

void pre()
{
	memset(p, true, sizeof(p));
	for(int i = 2; i < N; i++)
	{
		if( p[i] )
		{
			pri[pcnt++] = i;

			for(int j = i*i; j < N; j += i)
				p[j] = false;
		}
	}
}

int main()
{
	pre();
	int n;
	scanf("%d", &n);

	for(; n > 0; n--)
	{
		lld a,b;
		scanf("%lld %lld", &a, &b);

		bool ans = true;

		for(int i = 0; ans && i < pcnt; i++)
		{
			int p = 0, q = 0;
			for(; a > 1 && a%pri[i] == 0; a /= pri[i])
				p++;
			for(; b > 1 && b%pri[i] == 0; b /= pri[i])
				q++;

			if( (2*p-q)%3 != 0 || (2*p-q) < 0 )
				ans = false;
			else if( (2*q-p)%3 != 0 || (2*q-p) < 0 )
				ans = false;
		}

		ans &= a == b;
		puts(ans ? "YES" : "NO");
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;
typedef long long lld;
const int N = 35000;
bool p[N];
int pri[N];
int pcnt = 0;

void pre()
{
	memset(p, true, sizeof(p));
	for(lld i = 2; i < N; i++)
	{
		if( p[i] )
		{
			pri[pcnt++] = i;

			for(lld j = i*i; j < N; j += i)
				p[j] = false;
		}
	}
}

int main()
{
	pre();
	int n;
	scanf("%d", &n);

	for(; n > 0; n--)
	{
		int a,b;
		scanf("%d %d", &a, &b);

		bool ans = true;

		for(int i = 0; ans && i < pcnt; i++)
		{
			int p = 0, q = 0;
			for(; a > 1 && a%pri[i] == 0; a /= pri[i])
				p++;
			for(; b > 1 && b%pri[i] == 0; b /= pri[i])
				q++;

			if( (2*p-q)%3 != 0 || (2*p-q) < 0 )
				ans = false;
			else if( (2*q-p)%3 != 0 || (2*q-p) < 0 )
				ans = false;
		}

		ans &= a == 1 && b == 1;
		puts(ans ? "YES" : "NO");
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;
typedef long long lld;

const lld N = 1010;
bool p[N];
int pri[N];
int pcnt = 0;

void pre()
{
	memset(p, true, sizeof(p));
	for(int i = 2; i < N; i++)
	{
		if( p[i] )
		{
			pri[pcnt++] = i;

			for(int j = i*i; j < N; j += i)
				p[j] = false;
		}
	}
}

int main()
{
	pre();
	int n;
	scanf("%d", &n);

	for(; n > 0; n--)
	{
		lld a,b;
		scanf("%lld %lld", &a, &b);

		bool ans = true;

		for(int i = 0; ans && i < pcnt; i++)
		{
			int p = 0, q = 0;
			for(; a > 0 && a%pri[i] == 0; a /= pri[i])
				p++;
			for(; b > 0 && b%pri[i] == 0; b /= pri[i])
				q++;

			if( (2*p-q)%3 != 0 || (2*p-q) < 0 )
				ans = false;
			else if( (2*q-p)%3 != 0 || (2*q-p) < 0 )
				ans = false;
		}

		ans &= a == b;
		puts(ans ? "YES" : "NO");
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;
typedef long long lld;

const lld N = 10000;
bool p[N];
int pri[N];
int pcnt = 0;

void pre()
{
	memset(p, true, sizeof(p));
	for(int i = 2; i < N; i++)
	{
		if( p[i] )
		{
			pri[pcnt++] = i;

			for(int j = i*i; j < N; j += i)
				p[j] = false;
		}
	}
}

int main()
{
	pre();

	int n;
	scanf("%d", &n);

	for(; n > 0; n--)
	{
		lld a,b;
		scanf("%lld %lld", &a, &b);

		lld c = a*b;
		bool ans = true;

		for(int i = 0; i < pcnt; i++)
		{
			int cnt = 0;
			for(; c > 0 && c%pri[i] == 0; c /= pri[i])
				cnt++;

			ans &= cnt%3 == 0;
		}

		ans &= c == 1;

		puts(ans ? "YES" : "NO");
	}

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;
const int N = 1010;
bool p[N];
int pri[N];
int pcnt = 0;

void pre()
{
	memset(p, true, sizeof(p));
	for(int i = 2; i < N; i++)
	{
		if( p[i] )
		{
			pri[pcnt++] = i;

			for(int j = i*i; j < N; j += i)
				p[j] = false;
		}
	}
}

int main()
{
	pre();
	int n;
	scanf("%d", &n);

	for(; n > 0; n--)
	{
		int a,b;
		scanf("%d %d", &a, &b);

		bool ans = true;

		for(int i = 0; ans && i < pcnt; i++)
		{
			int p = 0, q = 0;
			for(; a > 1 && a%pri[i] == 0; a /= pri[i])
				p++;
			for(; b > 1 && b%pri[i] == 0; b /= pri[i])
				q++;

			if( (2*p-q)%3 != 0 || (2*p-q) < 0 )
				ans = false;
			else if( (2*q-p)%3 != 0 || (2*q-p) < 0 )
				ans = false;
		}

		ans &= (b%a == 0 && b/a==a) || (a%b == 0 && a/b==b) || (a == 1 && b == 1);
		puts(ans ? "YES" : "NO");
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;
typedef long long lld;

const lld N = 10000;
bool p[N];
int pri[N];
int pcnt = 0;

void pre()
{
	memset(p, true, sizeof(p));
	for(int i = 2; i < N; i++)
	{
		if( p[i] )
		{
			pri[pcnt++] = i;

			for(int j = i*i; j < N; j += i)
				p[j] = false;
		}
	}
}

int main()
{
	pre();

	int n;
	scanf("%d", &n);

	for(; n > 0; n--)
	{
		lld a,b;
		scanf("%lld %lld", &a, &b);

		lld c = a*b;
		bool ans = true;

		for(int i = 0; i < pcnt; i++)
		{
			int cnt = 0;
			for(; c > 0 && c%pri[i] == 0; c /= pri[i])
				cnt++;

			ans &= cnt%3 == 0;
		}

		if( ans )
			puts("YES");
		else
			puts("NO");
	}

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;

const int N = 50000;
bool p[N];
int pri[N];
int pcnt = 0;

void pre()
{
	memset(p, true, sizeof(p));
	for(int i = 2; i < N; i++)
	{
		if( p[i] )
		{
			pri[pcnt++] = i;

			for(int j = i*i; j < N; j += i)
				p[j] = false;
		}
	}
}

int main()
{
	pre();
	int n;
	scanf("%d", &n);

	for(; n > 0; n--)
	{
		int a,b;
		scanf("%d %d", &a, &b);

		bool ans = true;

		for(int i = 0; ans && i < pcnt; i++)
		{
			int p = 0, q = 0;
			for(; a > 1 && a%pri[i] == 0; a /= pri[i])
				p++;
			for(; b > 1 && b%pri[i] == 0; b /= pri[i])
				q++;

			if( (2*p-q)%3 != 0 || (2*p-q) < 0 )
				ans = false;
			else if( (2*q-p)%3 != 0 || (2*q-p) < 0 )
				ans = false;
		}

		ans &= a == 1 && b == 1;
		puts(ans ? "YES" : "NO");
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;
typedef long long lld;

const lld N = 2000;
bool p[N];
int pri[N];
int pcnt = 0;

void pre()
{
	memset(p, true, sizeof(p));
	for(lld i = 2; i < N; i++)
	{
		if( p[i] )
		{
			pri[pcnt++] = i;

			for(lld j = i*i; j < N; j += i)
				p[j] = false;
		}
	}
}

int main()
{
	pre();
	int n;
	scanf("%d", &n);

	for(; n > 0; n--)
	{
		lld a,b;
		scanf("%lld %lld", &a, &b);

		bool ans = true;

		for(int i = 0; i < pcnt; i++)
		{
			int p = 0, q = 0;
			for(; a > 0 && a%pri[i] == 0; a /= pri[i])
				p++;
			for(; b > 0 && b%pri[i] == 0; b /= pri[i])
				q++;

			if( (2*p-q)%3 != 0 || (2*p-q) < 0 )
				ans = false;
			if( (2*q-p)%3 != 0 || (2*q-p) < 0 )
				ans = false;
		}

		ans &= a == b;
		puts(ans ? "YES" : "NO");
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;
typedef long long lld;

const lld N = 10000;
bool p[N];
int pri[N];
int pcnt = 0;

void pre()
{
	memset(p, true, sizeof(p));
	for(lld i = 2; i < N; i++)
	{
		if( p[i] )
		{
			pri[pcnt++] = i;

			for(lld j = i*i; j < N; j += i)
				p[j] = false;
		}
	}
}

int main()
{
	pre();
	int n;
	scanf("%d", &n);

	for(; n > 0; n--)
	{
		lld a,b;
		scanf("%lld %lld", &a, &b);

		bool ans = true;

		for(int i = 0; i < pcnt; i++)
		{
			int p = 0, q = 0;
			for(; a > 0 && a%pri[i] == 0; a /= pri[i])
				p++;
			for(; b > 0 && b%pri[i] == 0; b /= pri[i])
				q++;

			if( (2*p-q)%3 != 0 || (2*p-q) < 0 )
				ans = false;
			if( (2*q-p)%3 != 0 || (2*q-p) < 0 )
				ans = false;
		}

		ans &= a == b;
		puts(ans ? "YES" : "NO");
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;
typedef long long lld;
const int N = 50000;
bool p[N];
int pri[N];
int pcnt = 0;

void pre()
{
	memset(p, true, sizeof(p));
	for(lld i = 2; i < N; i++)
	{
		if( p[i] )
		{
			pri[pcnt++] = i;

			for(lld j = i*i; j < N; j += i)
				p[j] = false;
		}
	}
}

int main()
{
	pre();
	int n;
	scanf("%d", &n);

	for(; n > 0; n--)
	{
		int a,b;
		scanf("%d %d", &a, &b);

		bool ans = true;

		for(int i = 0; ans && i < pcnt; i++)
		{
			int p = 0, q = 0;
			for(; a > 1 && a%pri[i] == 0; a /= pri[i])
				p++;
			for(; b > 1 && b%pri[i] == 0; b /= pri[i])
				q++;

			if( (2*p-q)%3 != 0 || (2*p-q) < 0 )
				ans = false;
			else if( (2*q-p)%3 != 0 || (2*q-p) < 0 )
				ans = false;
		}

		ans &= a == 1 && b == 1;
		puts(ans ? "YES" : "NO");
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;
typedef long long lld;

const lld N = 2000000;
bool p[N];
int pri[N];
int pcnt = 0;

void pre()
{
	memset(p, true, sizeof(p));
	for(lld i = 2; i < N; i++)
	{
		if( p[i] )
		{
			pri[pcnt++] = i;

			for(lld j = i*i; j < N; j += i)
				p[j] = false;
		}
	}
}

int main()
{
	pre();
	int n;
	scanf("%d", &n);

	for(; n > 0; n--)
	{
		lld a,b;
		scanf("%lld %lld", &a, &b);

		lld c = a*b;
		bool ans = true;

		for(int i = 0; i < pcnt; i++)
		{
			int cnt = 0;
			for(; c > 0 && c%pri[i] == 0; c /= pri[i])
				cnt++;

			ans &= cnt%3 == 0;
		}

		ans &= c == 1;

		puts(ans ? "YES" : "NO");
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;

const int N = 1010;
bool p[N];
int pri[N];
int pcnt = 0;

void pre()
{
	memset(p, true, sizeof(p));
	for(int i = 2; i < N; i++)
	{
		if( p[i] )
		{
			pri[pcnt++] = i;

			for(int j = i*i; j < N; j += i)
				p[j] = false;
		}
	}
}

int main()
{
	pre();
	int n;
	scanf("%d", &n);

	for(; n > 0; n--)
	{
		int a,b;
		scanf("%d %d", &a, &b);

		bool ans = true;

		for(int i = 0; ans && i < pcnt; i++)
		{
			int p = 0, q = 0;
			for(; a > 1 && a%pri[i] == 0; a /= pri[i])
				p++;
			for(; b > 1 && b%pri[i] == 0; b /= pri[i])
				q++;

			if( (2*p-q)%3 != 0 || (2*p-q) < 0 )
				ans = false;
			else if( (2*q-p)%3 != 0 || (2*q-p) < 0 )
				ans = false;
		}

		ans &= a == 1 && b == 1;
		puts(ans ? "YES" : "NO");
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;
typedef long long lld;

const lld N = 1100;
bool p[N];
int pri[N];
int pcnt = 0;

void pre()
{
	memset(p, true, sizeof(p));
	for(lld i = 2; i < N; i++)
	{
		if( p[i] )
		{
			pri[pcnt++] = i;

			for(lld j = i*i; j < N; j += i)
				p[j] = false;
		}
	}
}

int main()
{
	pre();
	int n;
	scanf("%d", &n);

	for(; n > 0; n--)
	{
		lld a,b;
		scanf("%lld %lld", &a, &b);

		bool ans = true;

		for(int i = 0; i < pcnt; i++)
		{
			int p = 0, q = 0;
			for(; a > 0 && a%pri[i] == 0; a /= pri[i])
				p++;
			for(; b > 0 && b%pri[i] == 0; b /= pri[i])
				q++;

			if( (2*p-q)%3 != 0 || (2*p-q) < 0 )
				ans = false;
			if( (2*q-p)%3 != 0 || (2*q-p) < 0 )
				ans = false;
		}

		ans &= a == b;
		puts(ans ? "YES" : "NO");
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;

const int N = 1010;
bool p[N];
int pri[N];
int pcnt = 0;

void pre()
{
	memset(p, true, sizeof(p));
	for(int i = 2; i < N; i++)
	{
		if( p[i] )
		{
			pri[pcnt++] = i;

			for(int j = i*i; j < N; j += i)
				p[j] = false;
		}
	}
}

int main()
{
	pre();
	int n;
	scanf("%d", &n);

	for(; n > 0; n--)
	{
		lld a,b;
		scanf("%d %d", &a, &b);

		bool ans = true;

		for(int i = 0; ans && i < pcnt; i++)
		{
			int p = 0, q = 0;
			for(; a > 1 && a%pri[i] == 0; a /= pri[i])
				p++;
			for(; b > 1 && b%pri[i] == 0; b /= pri[i])
				q++;

			if( (2*p-q)%3 != 0 || (2*p-q) < 0 )
				ans = false;
			else if( (2*q-p)%3 != 0 || (2*q-p) < 0 )
				ans = false;
		}

		ans &= a == 1 && b == 1;
		puts(ans ? "YES" : "NO");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define PI M_PI
const ll mod = 1000000007;
const int INF = 2123456789;
const double eps = 1e-7;

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        ll a, b;
        scanf("%I64d%I64d", &a, &b);
        ll ab = (ll)(cbrt((long double)a * b));
        bool flag = 0;
        if(ab * ab * ab == a * b && a % ab == 0 && b % ab == 0)flag = 1;
        if(flag){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define PI M_PI
const ll mod = 1000000007;
const int INF = 2123456789;
const double eps = 1e-7;

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        ll a, b;
        scanf("%lld%lld", &a, &b);
        ll now = a * b;
        ll ab = (ll)(cbrt(a * b));
        bool flag = 0;
        if(i == 1){
            if(a == ab || b == ab)flag = 1;
        }
        else{
            if(a == 0 && b == 0)flag = 1;
            else if(a % ab == 0 && b % ab == 0)flag = 1;
        }
        if(flag){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define PI M_PI
const ll mod = 1000000007;
const int INF = 2123456789;
const double eps = 1e-7;

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        ll a, b;
        scanf("%lld%lld", &a, &b);
        ll now = a * b;
        ll haha = (ll)(pow(now, 1.0 / 3)) - 5;
        if(haha < 0)haha = 0;
        bool flag = 0;
        for(ll j = haha; j <= haha + 10; j++){
            if(j * j * j == now){
                if(i == 1){
                    if(a == j || b == j)flag = 1;
                }
                else{
                    if(a % j == 0 && b % j == 0)flag = 1;
                }
                break;
            }
        }
        if(flag){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define PI M_PI
const ll mod = 1000000007;
const int INF = 2123456789;
const double eps = 1e-7;

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        ll a, b;
        scanf("%lld%lld", &a, &b);
        ll ab = cbrt((long double)a * b);
        ll A = a / ab, B = b / ab;
        if(i == 1){
            if(a == ab || b == ab){
                printf("Yes\n");
            }
            else printf("No\n");
        }
        else{
            if(A * A * B == a && A * B * B == b){
                printf("Yes\n");
            }
            else{
                printf("No\n");
            }
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define PI M_PI
const ll mod = 1000000007;
const int INF = 2123456789;
const double eps = 1e-7;

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        ll a, b;
        scanf("%lld%lld", &a, &b);
        ll now = a * b;
        ll haha = (ll)(pow(now, 1.0 / 3)) - 1;
        if(haha < 0)haha = 0;
        bool flag = 0;
        for(ll j = haha; j <= haha + 3; j++){
            if(j * j * j == now){
                if(i == 1){
                    if(a == j || b == j)flag = 1;
                }
                else{
                    if(a % j == 0 && b % j == 0)flag = 1;
                }
                break;
            }
        }
        if(flag){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define PI M_PI
const ll mod = 1000000007;
const int INF = 2123456789;
const double eps = 1e-7;

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        ll a, b;
        scanf("%I64d%I64d", &a, &b);
        ll ab = (ll)(cbrt((long double)a * b));
        bool flag = 0;
        if(a == 0 && b == 0)flag = 1;
        else if(ab * ab * ab == a * b && a % ab == 0 && b % ab == 0)flag = 1;
        if(flag){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define PI M_PI
const ll mod = 1000000007;
const int INF = 2123456789;
const double eps = 1e-7;

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

int solve(ll n)
{
    int ans = 0;
    for(ll i = 2; i <= n; i++){
        if(n % i == 0){
            n /= i;
            ans++;
            i--;
        }
    }
    return ans;
}

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        ll a, b;
        scanf("%I64d%I64d", &a, &b);
        ll now = a * b;
        ll haha = (ll)(pow(now, 1.0 / 3) - 5);
        if(haha < 0)haha = 0;
        bool flag = 0;
        for(ll j = haha; j <= haha + 10; j++){
            if(j * j * j == now){
                flag = 1;
                break;
            }
        }
        if(flag){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define PI M_PI
const ll mod = 1000000007;
const int INF = 2123456789;
const double eps = 1e-7;

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        ll a, b;
        scanf("%lld%lld", &a, &b);
        ll ab = cbrt((long double)a * b);
        ll A = a / ab, B = b / ab;
        if(A * A * B == a && A * B * B == b){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define PI M_PI
const ll mod = 1000000007;
const int INF = 2123456789;
const double eps = 1e-7;

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        ll a, b;
        scanf("%lld%lld", &a, &b);
        ll now = a * b;
        ll ab = (ll)(cbrt((long double)a * b));
        bool flag = 0;
        if(a == 0 && b == 0)flag = 1;
        else if(a % ab == 0 && b % ab == 0)flag = 1;
        if(flag){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define PI M_PI
const ll mod = 1000000007;
const int INF = 2123456789;
const double eps = 1e-7;

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        long double a, b;
        scanf("%lf%lf", &a, &b);
        ll now = a * b;
        ll ab = (ll)(cbrt((long double)a * b));
        bool flag = 0;
        if(i == 1){
            if(a == ab || b == ab)flag = 1;
        }
        else{
            if(a == 0 && b == 0)flag = 1;
            else if(a % ab == 0 && b % ab == 0)flag = 1;
        }
        if(flag){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define PI M_PI
const ll mod = 1000000007;
const int INF = 2123456789;
const double eps = 1e-7;

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        ll a, b;
        scanf("%I64d%I64d", &a, &b);
        ll now = a * b;
        ll ab = (ll)(cbrt((long double)a * b));
        bool flag = 0;
        if(i == 1){
            if(a == ab || b == ab)flag = 1;
        }
        else{
            if(a == 0 && b == 0)flag = 1;
            else if(a % ab == 0 && b % ab == 0)flag = 1;
        }
        if(flag){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define PI M_PI
const ll mod = 1000000007;
const int INF = 2123456789;
const double eps = 1e-7;

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

int solve(ll n)
{
    int ans = 0;
    for(ll i = 2; i <= n; i++){
        if(n % i == 0){
            n /= i;
            ans++;
            i--;
        }
    }
    return ans;
}

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        ll a, b;
        scanf("%I64d%I64d", &a, &b);
        ll now = a * b;
        ll haha = floor(pow(now, 1.0 / 3) + 0.5) - 5;
        bool flag = 0;
        for(ll j = haha; j <= haha + 5; j++){
            if(j * j * j == now){
                flag = 1;
                break;
            }
        }
        if(flag){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define PI M_PI
const ll mod = 1000000007;
const int INF = 2123456789;
const double eps = 1e-7;

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        ll a, b;
        scanf("%lld%lld", &a, &b);
        ll now = a * b;
        ll haha = (ll)(pow(now, 1.0 / 3)) - 5;
        if(haha < 0)haha = 0;
        bool flag = 0;
        for(ll j = haha; j <= haha + 10; j++){
            if(j * j * j == now){
                if(a % j == 0 && b % j == 0)flag = 1;
                break;
            }
        }
        if(flag){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define PI M_PI
const ll mod = 1000000007;
const int INF = 2123456789;
const double eps = 1e-7;

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        ll a, b;
        scanf("%lld%lld", &a, &b);
        ll now = a * b;
        ll ab = (ll)(cbrt(a * b));
        bool flag = 0;
        if(a == 0 && b == 0)flag = 1;
        else if(a % ab == 0 && b % ab == 0)flag = 1;
        if(flag){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define PI M_PI
const ll mod = 1000000007;
const int INF = 2123456789;
const double eps = 1e-7;

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        ll a, b;
        scanf("%lld%lld", &a, &b);
        ll now = a * b;
        ll haha = (ll)(pow(now, 1.0 / 3)) - 1;
        if(haha < 0)haha = 0;
        bool flag = 0;
        for(ll j = haha; j <= haha + 3; j++){
            if(j * j * j == now){
                if(i == 1){
                    if(a == j || b != j)flag = 1;
                }
                else{
                    if(a % j == 0 && b % j == 0)flag = 1;
                }
                break;
            }
        }
        if(flag){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define PI M_PI
const ll mod = 1000000007;
const int INF = 2123456789;
const double eps = 1e-7;

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        ll a, b;
        scanf("%I64d%I64d", &a, &b);
        ll now = a * b;
        ll ab = (ll)(cbrt((long double)a * b));
        bool flag = 0;
        if(a % ab == 0 && b % ab == 0)flag = 1;
        if(flag){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int inf=1e9;
const double PI=acos(-1);
const double eps=1e-6;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
int a,b;
bool bo[maxn];
int f[maxn],len;
void init(int n){
    bo[0]=bo[1]=1;
    for(int i=2;i<=n;i++)
    {
        if(!bo[i])
        f[++len]=i;
        for(int j=1;j<=len;j++)
        {
            if(i*f[j]>n)break;
            bo[i*f[j]]=1;
            if(i%f[j]==0)break;//如果i是prime[j]的倍数，那么在筛i时已经筛过prime[j]的倍数了，所以跳出
        }
    }
}
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	init(sqrt(inf+10));
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a,&b);
		int c1=0,c2=0,flag=1;
		for(int i=1;f[i]*f[i]<=max(a,b)&&i<=len;i++){
			c1=c2=0;
			while(a%f[i]==0){
				a/=f[i];
				c1++;
			}
			while(b%f[i]==0){
				b/=f[i];
				c2++;
			}
			//if(c1==c2) continue;
			if(c1==0&&c2==0) continue;
			if((c1*2-c2)%3==0&&(c2*2-c1)%3==0&&c1>0&&c2>0&&(c1*2-c2)>0&&(c2*2-c1)>0){

			}else{
				flag=0;
				break;
			}
		}
		if(a>1||b>1||!flag){
			puts("NO");
			continue;
		}
		if(flag) puts("YES");
	}
	return 0;
}
/*2*x+y=c1
x+2*y=c2

c1*2-c2=3*x
y=c1*2-c2-3*x=c2-x
320013504 776151559
*/


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int inf=1e9;
const double PI=acos(-1);
const double eps=1e-6;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
ll a,b;
bool check(ll k){
	for(ll i=1;i*i<=k;i++){
		if(k%i==0){
			ll x=i,y=k/i;
			if(x<y) swap(x,y);
			if(x*x*y==a&&y*y*x==b) return 1;
		}
	}
	return 0;
}
int main(){
	ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n;
	while(n--){
		cin>>a>>b;
		if(a<b) swap(a,b);
		ll l=1,r=1e6+1;
		while(l<=r){
			ll mid=l+r>>1;
			if(mid*mid*mid<=a*b) l=mid+1;
			else r=mid-1;
		}
		if(r*r*r==a*b&&check(r)){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int inf=1e9;
const double PI=acos(-1);
const double eps=1e-6;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
int a,b;
bool bo[maxn];
int f[maxn],len;
void init(int n){
    bo[0]=bo[1]=1;
    for(int i=2;i<=n;i++)
    {
        if(!bo[i])
        f[++len]=i;
        for(int j=1;j<=len;j++)
        {
            if(i*f[j]>n)break;
            bo[i*f[j]]=1;
            if(i%f[j]==0)break;//如果i是prime[j]的倍数，那么在筛i时已经筛过prime[j]的倍数了，所以跳出
        }
    }
}
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	init(sqrt(inf+10));
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a,&b);
		int c1=0,c2=0,flag=1;
		for(int i=1;f[i]*f[i]<=max(a,b)&&i<=len;i++){
			c1=c2=0;
			while(a%f[i]==0){
				a/=f[i];
				c1++;
			}
			while(b%f[i]==0){
				b/=f[i];
				c2++;
			}
			//if(c1==c2) continue;
			if(c1==0&&c2==0) continue;
			if((c1*2-c2)%3==0&&(c2*2-c1)%3==0&&c1>0&&c2>0&&(c1*2-c2)>=0&&(c2*2-c1)>=0){

			}else{
				flag=0;
				break;
			}
		}
		if(a>1||b>1||!flag){
			puts("NO");
			continue;
		}
		if(flag) puts("YES");
	}
	return 0;
}
/*2*x+y=c1
x+2*y=c2

c1*2-c2=3*x
y=c1*2-c2-3*x=c2-x
320013504 776151559
*/


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int inf=1e9;
const double PI=acos(-1);
const double eps=1e-6;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
int a,b;
bool bo[maxn];
int f[maxn],len;
void init(int n){
    bo[0]=bo[1]=1;
    for(int i=2;i<=n;i++)
    {
        if(!bo[i])
        f[++len]=i;
        for(int j=1;j<=len;j++)
        {
            if(i*f[j]>n)break;
            bo[i*f[j]]=1;
            if(i%f[j]==0)break;//如果i是prime[j]的倍数，那么在筛i时已经筛过prime[j]的倍数了，所以跳出
        }
    }
}
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	init(sqrt(inf+10));
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a,&b);
		if(i==46){
			cout<<a<<" "<<b<<endl;
		}
		int c1=0,c2=0,flag=1;
		for(int i=1;f[i]*f[i]<=max(a,b)&&i<=len;i++){
			c1=c2=0;
			while(a%f[i]==0){
				a/=f[i];
				c1++;
			}
			while(b%f[i]==0){
				b/=f[i];
				c2++;
			}
			//if(c1==c2) continue;
			if((c1*2-c2)%3==0&&(c2*2-c1)%3==0){

			}else{
				flag=0;
				break;
			}
		}
		if(a>1||b>1||!flag){
			puts("NO");
			continue;
		}
		if(flag) puts("YES");
	}
	return 0;
}
/*2*x+y=c1
x+2*y=c2

c1*2-c2=3*x
y=c1*2-c2-3*x=c2-x*/


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int inf=1e9;
const double PI=acos(-1);
const double eps=1e-6;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
ll a,b;
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&a,&b);
		if(i==46) cout<<a<<" "<<b<<endl;
		ll l=1,r=1e6+10;
		while(l<=r){
			ll mid=l+r>>1;
			if(mid*mid*mid>=a*b) r=mid-1;
			else l=mid+1;
		}
		if(l*l*l==a*b){
			puts("Yes");
		}else puts("NO");
	}
	return 0;
}
//x*y=k;
//y^2*x==a;
//x^2*y==b;


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int inf=1e9;
const double PI=acos(-1);
const double eps=1e-6;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
ll a,b;
int main(){
	ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n;
	while(n--){
		cin>>a>>b;
		if(a<b) swap(a,b);
		ll l=1,r=1e6;
		while(l<=r){
			ll mid=l+r>>1;
			if(mid*mid*mid<=a*b) l=mid+1;
			else r=mid-1;
		}
		if(r*r*r==a*b){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int inf=1e9;
const double PI=acos(-1);
const double eps=1e-6;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
ll a,b;
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&a,&b);
		ll l=1,r=1e6+10;
		while(l<=r){
			ll mid=l+r>>1;
			if(mid*mid*mid>=a*b) r=mid-1;
			else l=mid+1;
		}
		if(l*l*l==a*b){
			puts("Yes");
		}else puts("NO");
	}
	return 0;
}
//x*y=k;
//y^2*x==a;
//x^2*y==b;


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int inf=1e9;
const double PI=acos(-1);
const double eps=1e-6;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
ll a,b;
bool check(ll x){
	if(a==b){
		ll l=1,r=1e6;
		while(l<=r){
			ll mid=l+r>>1;
			if(mid*mid<=x) l=mid+1;
			else r=mid-1;
		}
		return r*r==x;
	}else{
		return x!=1;
	}
}
int main(){
	ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n;
	while(n--){
		cin>>a>>b;
		if(a<b) swap(a,b);
		ll l=1,r=a*b;
		while(l<=r){
			ll mid=l+r>>1;
			if(mid*mid*mid<=a*b) l=mid+1;
			else r=mid-1;
		}
		if(r*r*r==a*b&&check(r)){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int inf=1e9;
const double PI=acos(-1);
const double eps=1e-6;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
int a,b;
bool bo[maxn];
int f[maxn],len;
void init(int n){
    bo[0]=bo[1]=1;
    for(int i=2;i<=n;i++)
    {
        if(!bo[i])
        f[++len]=i;
        for(int j=1;j<=len;j++)
        {
            if(i*f[j]>n)break;
            bo[i*f[j]]=1;
            if(i%f[j]==0)break;//如果i是prime[j]的倍数，那么在筛i时已经筛过prime[j]的倍数了，所以跳出
        }
    }
}
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	init(sqrt(inf+10));
	scanf("%d",&n);
	while(n--){
		scanf("%d%d",&a,&b);
		int c1=0,c2=0,flag=1;
		for(int i=1;f[i]*f[i]<=max(a,b)&&i<=len;i++){
			c1=c2=0;
			while(a%f[i]==0){
				a/=f[i];
				c1++;
			}
			while(b%f[i]==0){
				b/=f[i];
				c2++;
			}
			//if(c1==c2) continue;
			if((c1*2-c2)%3==0&&(c2*2-c1)%3==0){

			}else{
				flag=0;
				break;
			}
		}
		if(a>1||b>1||!flag){
			puts("NO");
			continue;
		}
		if(flag) puts("YES");
	}
	return 0;
}
/*2*x+y=c1
x+2*y=c2

c1*2-c2=3*x
y=c1*2-c2-3*x=c2-x*/


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int inf=1e9;
const double PI=acos(-1);
const double eps=1e-6;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
ll a,b;
bool check(ll k){
	if(a%k==0&&b%k==0) return 1;
	return 0;
}
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	scanf("%d",&n);
	while(n--){
		scanf("%lld%lld",&a,&b);
		if(a<b) swap(a,b);
		ll l=1,r=1e6+1;
		while(l<=r){
			ll mid=l+r>>1;
			if(mid*mid*mid<=a*b) l=mid+1;
			else r=mid-1;
		}
		if(r*r*r==a*b&&check(r)){
			puts("Yes");
		}else{
			puts("No");
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int inf=1e9;
const double PI=acos(-1);
const double eps=1e-6;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
int a,b;
bool bo[maxn];
int f[maxn],len;
void init(int n){
    bo[0]=bo[1]=1;
    for(int i=2;i<=n;i++)
    {
        if(!bo[i])
        f[++len]=i;
        for(int j=1;j<=len;j++)
        {
            if(i*f[j]>n)break;
            bo[i*f[j]]=1;
            if(i%f[j]==0)break;//如果i是prime[j]的倍数，那么在筛i时已经筛过prime[j]的倍数了，所以跳出
        }
    }
}
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	init(sqrt(inf+10));
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a,&b);
		int c1=0,c2=0,flag=1;
		for(int i=1;f[i]*f[i]<=max(a,b)&&i<=len;i++){
			c1=c2=0;
			while(a%f[i]==0){
				a/=f[i];
				c1++;
			}
			while(b%f[i]==0){
				b/=f[i];
				c2++;
			}
			//if(c1==c2) continue;
			if((c1*2-c2)%3==0&&(c2*2-c1)%3==0&&c1>0&&c2>0||(c1==0&&c2==0)){

			}else{
				flag=0;
				break;
			}
		}
		if(a>1||b>1||!flag){
			puts("NO");
			continue;
		}
		if(flag) puts("YES");
	}
	return 0;
}
/*2*x+y=c1
x+2*y=c2

c1*2-c2=3*x
y=c1*2-c2-3*x=c2-x
320013504 776151559
*/


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int inf=1e9;
const double PI=acos(-1);
const double eps=1e-6;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
ll a,b;
bool check(ll k){
	if(a%k==0&&b%k==0) return 1;
	return 0;
}
int main(){
	ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n;
	while(n--){
		cin>>a>>b;
		if(a<b) swap(a,b);
		ll l=1,r=1e6+1;
		while(l<=r){
			ll mid=l+r>>1;
			if(mid*mid*mid<=a*b) l=mid+1;
			else r=mid-1;
		}
		if(r*r*r==a*b&&check(r)){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int inf=1e9;
const double PI=acos(-1);
const double eps=1e-6;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
ll a,b;
bool check(ll k){
	if(k%a==0&&k%b==0) return 1;
	return 0;
}
int main(){
	ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n;
	while(n--){
		cin>>a>>b;
		if(a<b) swap(a,b);
		ll l=1,r=1e6+1;
		while(l<=r){
			ll mid=l+r>>1;
			if(mid*mid*mid<=a*b) l=mid+1;
			else r=mid-1;
		}
		if(r*r*r==a*b&&check(r)){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int inf=1e9;
const double PI=acos(-1);
const double eps=1e-6;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
ll a,b;
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&a,&b);
		if(i==46) cout<<a<<" "<<b<<endl;
		ll l=1,r=1e6+10;
		while(l<=r){
			ll mid=l+r>>1;
			if(mid*mid*mid>=a*b) r=mid-1;
			else l=mid+1;
		}
		if(l*l*l==a*b&&a%l==0&&b%l==0){
			puts("Yes");
		}else puts("NO");
	}
	return 0;
}
//x*y=k;
//y^2*x==a,320013504 776151559;
//x^2*y==b;


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int inf=1e9;
const double PI=acos(-1);
const double eps=1e-6;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
ll a,b;
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&a,&b);
		ll l=1,r=1e6+10;
		while(l<=r){
			ll mid=l+r>>1;
			if(mid*mid*mid>=a*b) r=mid-1;
			else l=mid+1;
		}
		if(l*l*l==a*b&&a%l==0&&b%l==0){
			puts("Yes");
		}else puts("NO");
	}
	return 0;
}
//x*y=k;
//y^2*x==a,320013504 776151559;
//x^2*y==b;


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int inf=1e9;
const double PI=acos(-1);
const double eps=1e-6;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
int a,b;
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a,&b);
		if(a>b) swap(a,b);
		int x,y,flag=0;
		for(int i=1;i*i*i<=inf;i++){
			y=i;x=a/(y*y);
			if(a%(y*y)==0){
				if(x*x*y==b){
					flag=1;
					break;
				}
			}
		}
		if(flag) puts("YES");
		else puts("NO");
	}
	return 0;
}
//y^2*x==a;
//x^2*y==b;


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int inf=1e9;
const double PI=acos(-1);
const double eps=1e-6;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
ll a,b;
bool check(ll x){
	if(a==b){
		ll l=1,r=1e6;
		while(l<=r){
			ll mid=l+r>>1;
			if(mid*mid<=x) l=mid+1;
			else r=mid-1;
		}
		return r*r==x;
	}else{
		return x!=1;
	}
}
int main(){
	ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n;
	while(n--){
		cin>>a>>b;
		if(a<b) swap(a,b);
		ll l=1,r=1e6;
		while(l<=r){
			ll mid=l+r>>1;
			if(mid*mid*mid<=a*b) l=mid+1;
			else r=mid-1;
		}
		if(r*r*r==a*b&&check(r)){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;
#define debug false

int64_t cube_root(int64_t x) {
    int64_t l = 0, r = 100000, m;
    while (l != r) {
        m = (l + r + 1) / 2;
        if (m * m * m > x) {
            r = m - 1;
        } else {
            l = m;
        }
    }

    return l;
}

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    int64_t x, y;
    while (n-- > 0) {
        cin >> x >> y;

        int64_t c = cube_root(x * y);
        if (c * c * c != x * y) {
            cout << "No";
        } else {
            if (x % c == 0 && y % c == 0) {
                cout << "Yes";
            } else {
                cout << "No";
            }
        }
        cout << "\n";
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;
#define debug false

int64_t cube_root(int64_t x) {
    int64_t l = 0, r = 1000001, m;
    while (l != r) {
        m = (l + r + 1) / 2;
        int64_t c = m * m * m;
        if (c > x) {
            r = m - 1;
        } else {
            l = m;
        }
    }

    return l;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    int64_t x, y;
    while (n-- > 0) {
        cin >> x >> y;

        int64_t c = cube_root(x * y);
        if (c * c * c != x * y) {
            puts("No");
        } else {
            if (x % c == 0 && y % c == 0) {
                puts("Yes");
            } else {
                puts("No");
            }
        }
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;

#define debug false

int main() {
    ios::sync_with_stdio(false);

    int pr_size = 31621;
    bool is_prime[31621];
    for (int i = 2; i < pr_size; i++) {
        is_prime[i] = true;
    }
    int tind = 0;
    int primes[3401];

    for (int i = 2; i < pr_size; i++) {
        if (is_prime[i]) {
            primes[tind++] = i;
            for (int j = i + i; j < pr_size; j += i) {
                is_prime[j] = false;
            }
        }
    }

    int n;
    cin >> n;

    long x, y;
    bool is_fine;

    int prime_index = 0;
    int prime, cx, cy;
    while (n-- > 0) {
        cin >> x >> y;

        prime_index = 0;
        is_fine = true;
        while (x > 1 && y > 1 && is_fine && prime_index < pr_size) {
            prime = primes[prime_index++];
            cx = 0, cy = 0;

            while (x % prime == 0) {
                x /= prime;
                cx++;
            }

            while (y % prime == 0) {
                y /= prime;
                cy++;
            }

            is_fine = (cx + cy) % 3 == 0 && (cx >= cy ? cx <= 2 * cy : cy <= 2 * cx) && (cx + cy == 0 || cx * cy != 0);
        }

        is_fine = is_fine && x == 1 && y == 1;

        cout << (is_fine ? "Yes" : "No") << "\n";
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;
#define debug false

int64_t cube_root(int64_t x) {
    int64_t l = 0, r = 1000001, m;
    while (l != r) {
        m = (l + r + 1) / 2;
        if (m * m * m > x) {
            r = m - 1;
        } else {
            l = m;
        }
    }

    return l;
}

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    int64_t x, y;
    while (n-- > 0) {
        cin >> x >> y;

        int64_t c = cube_root(x * y);
        if (c * c * c != x * y) {
            cout << "No";
        } else {
            if (x % c == 0 && y % c == 0) {
                cout << "Yes";
            } else {
                cout << "No";
            }
        }
        cout << "\n";
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;

#define debug false

int main() {
    ios::sync_with_stdio(false);

    vector<bool> is_prime(32000, true);
    vector<int> primes;

    for (int i = 2; i < is_prime.size(); i++) {
        if (is_prime[i]) {
            for (int j = i + i; j < is_prime.size(); j += i) {
                is_prime[j] = false;
            }
            primes.push_back(i);
        }
    }

    int n;
    cin >> n;

    int64_t x, y;
    bool is_fine;
    while (n-- > 0) {
        cin >> x >> y;

        int prime_index = 0;
        int prime, cx, cy;
        is_fine = true;
        while (x > 1 && y > 1 && is_fine && prime_index < primes.size()) {
            prime = primes[prime_index++];
            cx = 0, cy = 0;

            while (x % prime == 0) {
                x /= prime;
                cx++;
            }

            while (y % prime == 0) {
                y /= prime;
                cy++;
            }

            is_fine = (cx + cy) % 3 == 0 && (2 * cx >= cy || 2 * cy >= cx) && (cx + cy == 0 || cx * cy != 0);
        }

        is_fine = is_fine && x == 1 && y == 1;

        cout << (is_fine ? "Yes" : "No") << "\n";
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;

#define debug false

int main() {
    ios::sync_with_stdio(false);

    vector<bool> is_prime(32000, true);
    vector<int> primes;

    for (int i = 2; i < is_prime.size(); i++) {
        if (is_prime[i]) {
            for (int j = i + i; j < is_prime.size(); j += i) {
                is_prime[j] = false;
            }
            primes.push_back(i);
        }
    }

    int n;
    cin >> n;

    int64_t x, y;
    bool is_fine;
    while (n-- > 0) {
        cin >> x >> y;

        int prime_index = 0;
        int prime, cx, cy;
        is_fine = true;
        while (x > 1 && y > 1 && is_fine) {
            prime = primes[prime_index++];
            cx = 0, cy = 0;

            while (x % prime == 0) {
                x /= prime;
                cx++;
            }

            while (y % prime == 0) {
                y /= prime;
                cy++;
            }

            is_fine = (cx + cy) % 3 == 0 && (2 * cx >= cy || 2 * cy >= cx);
        }

        cout << (is_fine ? "Yes" : "No") << "\n";
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;

#define debug false

int main() {
    ios::sync_with_stdio(false);

    vector<bool> is_prime(32000, true);
    vector<int> primes;

    for (int i = 2; i < is_prime.size(); i++) {
        if (is_prime[i]) {
            for (int j = i + i; j < is_prime.size(); j += i) {
                is_prime[j] = false;
            }
            primes.push_back(i);
        }
    }

    int n;
    cin >> n;

    int64_t x, y;
    bool is_fine;
    while (n-- > 0) {
        cin >> x >> y;

        int prime_index = 0;
        int prime, cx, cy;
        is_fine = true;
        while (x > 1 && y > 1 && is_fine) {
            if (prime_index == primes.size()) {
                return 1;
            }
            prime = primes[prime_index++];
            cx = 0, cy = 0;

            while (x % prime == 0) {
                x /= prime;
                cx++;
            }

            while (y % prime == 0) {
                y /= prime;
                cy++;
            }

            is_fine = (cx + cy) % 3 == 0 && (2 * cx >= cy || 2 * cy >= cx);
        }

        cout << (is_fine ? "Yes" : "No") << "\n";
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;

#define debug false

int main() {
    ios::sync_with_stdio(false);

    vector<bool> is_prime(32000, true);
    vector<int> primes;

    for (int i = 2; i < is_prime.size(); i++) {
        if (is_prime[i]) {
            for (int j = i + i; j < is_prime.size(); j += i) {
                is_prime[j] = false;
            }
            primes.push_back(i);
        }
    }

    int n;
    cin >> n;

    int64_t x, y;
    bool is_fine;
    while (n-- > 0) {
        cin >> x >> y;

        int prime_index = 0;
        int prime, cx, cy;
        is_fine = true;
        while (x > 1 && y > 1 && is_fine && prime_index < primes.size()) {
            prime = primes[prime_index++];
            cx = 0, cy = 0;

            while (x % prime == 0) {
                x /= prime;
                cx++;
            }

            while (y % prime == 0) {
                y /= prime;
                cy++;
            }

            is_fine = (cx + cy) % 3 == 0 && (cx >= cy ? cx <= 2 * cy : cy <= 2 * cx) && (cx + cy == 0 || cx * cy != 0);
        }

        is_fine = is_fine && x == 1 && y == 1;

        cout << (is_fine ? "Yes" : "No") << "\n";
    }

    return 0;
}


n = int(input())

l = sorted(map(int, input().split()))
l2 = l[n:]

for a in l[:n]:
	if a in l2:
		print('NO')
		exit()

print('YES')


n = int(input())

s = set()

for a in map(int, input().split()):
	if a in s:
		print('NO')
		exit()
	s.add(a)

print('YES')


n = int(input())
A = [int(x) for x in input().split()]
if (A[n] == A[n - 1]): print("NO")
else: print("YES")


n = int(input())
A = [int(x) for x in input().split()]
sorted(A, reverse=True)
if (A[n] == A[0]): print("NO")
else: print("YES")


n = int(input())
A = [int(x) for x in input().split()]
A.sort()
if (A[n] == A[n - 1]): print("NO")
else: print("YES")


n=int(input())
a=list(map(int, input().split(" ")))
mx = max(a)
k=0
for i in a:
    if (i<mx):
        k+=1
print("YES") if (k>=n) else print("NO")


n=int(input())
a=list(map(int, input().split(" ")))
mx = max(a)
k=0
for i in a:
    if (i==mx):
        k+=1
print("YES") if (k<=n) else print("NO")


n=int(input())
a=list(map(int, input().split(" ")))
a=sorted(a)
print("YES") if (a[n-1]<a[n]) else print("NO")


n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[n - 1] < a[n]:
    print("YES")
else:
    print("NO")


n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[n // 2 - 1] < a[n // 2]:
    print("YES")
else:
    print("NO")


n=int(input())
t=[int(x) for x in input().split()]
t.sort()
t1=t[:n]
t2=t[n:2*n]
if t1[0]<t2[0]:
	print('YES')
else:
	print('NO')


n=int(input())
t=[int(x) for x in input().split()]
t.sort()
t1=t[:n]
t2=t[n:2*n]

if t1[n-1]<t2[0]:
	print('YES')
else:
	print('NO')


n=int(input())
a=sorted(list(map(int,input().split())))
if a[2*n-1]>a[n-1]:
    print("YES")
else:
    print("NO")


n=int(input())
a=sorted(list(map(int,input().split())))
if a[n]>a[n-1]:
	print("YES")
else:
	print("NO")


n=int(input())
l=[]
l= [int(x) for x in input().split()]
l.sort()
s=l[n+1]
t=[]
print(s)
for i in range(n):
 t.append(l[i])
print(t)
if s not in t:
 print("YES")
else:
 print("NO")


n=int(input())
l=[]
l= [int(x) for x in input().split()]
l.sort()
print(l)
s=l[n]
for i in range(n):
 t.append(l[i])
if s not in t:
 print("YES")
else:
 print("NO")


n=int(input())
l=[]
l= [int(x) for x in input().split()]
l.sort()
s=l[n+1]
t=[]
for i in range(n):
 t.append(l[i])
if s not in t:
 print("YES")
else:
 print("NO")


n=int(input())
l=[]
l= [int(x) for x in input().split()]
sorted(l)
s=l[n]
t=[]
for i in range(n):
 t.append(l[i])
if s not in t:
 print("YES")
else:
 print("NO")


n=int(input())
l=[]
l= [int(x) for x in input().split()]
l.sort()
s=l[n]
t=[]
for i in range(n):
 t.append(l[i])
if s not in t:
 print("YES")
else:
 print("NO")


n=int(input())
l=[]
l= [int(x) for x in input().split()]
l.sort()
if(n>1):
 s=l[n+1]
else:
 s=l[0]
t=[]
for i in range(n):
 t.append(l[i])
if s not in t:
 print("YES")
else:
 print("NO")


n = int(input())
#n, m = map(int, input().split())
#s = input()
c = list(map(int, input().split()))
c.sort()
l = 1
k = c[0]
for i in range(1, n * 2):
    if k == c[i]:
        l += 1
    else:
        if l > 1:
            print('NO')
            break
        k = c[i]
        l = 1
else:
    if l > 1:
        print('NO')
    else:
        print('YES')


n = int(input())
#n, m = map(int, input().split())
#s = input()
c = list(map(int, input().split()))
c.sort()
if c[n] == c[n - 1]:
    print('NO')
else:
    print('YES')


n = int(input())
#n, m = map(int, input().split())
#s = input()
c = list(map(int, input().split()))
c.sort()
l = 1
k = c[0]
for i in range(1, n * 2):
    if k == c[i]:
        l += 1
    else:
        if l > n:
            print('NO')
            break
        k = c[i]
        l = 1
else:
    if l > n:
        print('NO')
    else:
        print('YES')


n=int(input())
a=input().split()
a=[int(i) for i in a]
c=0
for i in range(1,2*n):
	key=a[i]
	j=i-1
	#print("hello")
	#print(key,a[j])
	while (j>=0) and key<a[j]:
		a[j+1]=a[j]
		j-=1
	a[j+1]=key
#print (a)
for i in range(n):
	if a[i] >= a[n+i]:
		c=1
		break
if c==1:
	print("NO")
else :
	print("YES")


n=int(input())
a=input().split()
a=[int(i) for i in a]
c=0
for i in range(1,2*n):
	key=a[i]
	j=i-1
	#print("hello")
	#print(key,a[j])
	while (j>=0) and key<a[j]:
		a[j+1]=a[j]
		j-=1
	a[j+1]=key
#print (a)

if a[n-1] >= a[n]:
	print("NO")
else :
	print("YES")


n = int(input())
a = []
s = input()
t = s.split()
for k in t:
    if k != " ":
        a.append(k)

a = sorted(a)

if a[n-1] == a[n]:
    print("NO")
else:
    print("YES")


n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

a = sorted(a)

if a[n-1] == a[n]:
    print("NO")
else:
    print("YES")


n = int(input())
a = []
s = input()
t = s.split()
for k in t:
    if k != " ":
        a.append(int(k))

a = sorted(a)

if a[n-1] == a[n]:
    print("NO")
else:
    print("YES")


n = int(input())
a = []
s = input()
t = s.split()
for k in t:
    if k != " ":
        a.append(int(k))

a = sorted(a)

assert len(a) == 2*n

if a[n-1] == a[n]:
    print("NO")
else:
    print("YES")


n = int(input())
a = []
for i in range(2*n):
    a.append(int(input()))

a = sorted(a)

if a[n-1] == a[n]:
    print("NO")
else:
    print("YES")


n = int(input())
a = []
s = input()
t = s.split()
for i in range(2*n):
    a.append(int(s[2*i]))

a = sorted(a)

if a[n-1] == a[n]:
    print("NO")
else:
    print("YES")


n=int(input())
chessers=list(map(int,input().split()))
was=[]
chessers.sort()
chessers1=chessers[:n]
chessers2=chessers[n:]
flag=True
for i in chessers1:
    if i in chessers2:
        flag=False
        break
if flag==True:
    print('YES')
else:
    print('NO')


n=int(input())
chessers=list(map(int,input().split()))
was=[]
flag=True
for i in chessers:
    if i not in was:
        was.append(i)
    else:
        flag=False
        break
if flag==True:
    print('YES')
else:
    print('NO')


n = int(input())
A = sorted(map(int, input().split()))

print(('NO','YES')[A[n-1]<A[n]])


n = int(input())//2
A = sorted(map(int, input().split()))

print(('NO','YES')[A[n-1]<A[n]])


n = int(input())
a = sorted(map(int, input().split()))
if a[n - 1] < a[n]:
    print("YES")
else:
    print("NO")


n=int(input())
a=sorted(map(int,input.split()))
if a[n-1]<a[n]:
	print("YES")
else:
	print("NO")


n=int(input())
a=list(map(int,input().split()))
a.sort()
if a[n-1]==a[n]:
    print('NO')
else:
    print('YES')


n=int(input())
a=list(map(int,input().split()))
m=0
for i in range(2*n,n-1,-1):
    for j in range(i-1):
        if a[j]>a[j+1]:
            a[j],a[j+1]=a[j+1],a[j]
print('NO' if a[n]==a[n-1] else 'YES')


n=int(input())
a=list(map(int,input().split()))
m=0'''67'''
for i in range(2*n,n-1,-1):
    for j in range(i-1):
        if a[j]>a[j+1]:
            a[j],a[j+1]=a[j+1],a[j]
print('NO' if a[n]==a[n-1] else 'YES')


n = int(input())
num_list = sorted(list(map(int, input().split())))
middle = num_list[n]

for _ in range(n - 1, 0):
	if num_list[_] == middle:
		print('NO')
		exit(0)

print('YES')


n = int(input())
num_list = sorted(list(map(int, input().split())))
middle = num_list[n]

for _ in range(n - 1, -1, -1):
	if num_list[_] == middle:
		print('NO')
		exit(0)

print('YES')


n = int(input())
num_list = sorted(list(map(int, input().split())))
remain = num_list[n:]
s = set()

for _ in remain:
	s.add(_)

if len(s) != n:
	print('NO')
else:
	print('YES')


n = map(int, input())
num_list = sorted(list(map(int, input().split())))
remain = num_list[n:]
s = set()

for _ in remain:
	s.add(_)

if len(s) != n:
	print('NO')
else:
	print('YES')


n=int(input())
#k=[]
k=input().split()
i=0
k.sort()
if int(k[n])>=int(k[n-1]):
    print('YES')
else:
    print('NO')


n=int(input())
#k=[]
k=input().split()
i=0
k.sort()
if int(k[n])==int(k[n-1]):
    print('NO')
else:
    print('YES')


n=int(input())
s=input()
i=0
b=[]
j=0
l=1
chsl=0
while i < len(s):
    if s[i]==' ':
        b.append(chsl)
        l=1
        j+=1
        chsl=0
    else :
        chsl=chsl+int(s[i])*l
        l=l*10
    i+=1
b.append(chsl)
b.sort()
if int(b[n-1])==int(b[n]) :
    print('NO')
else:
    print('YES')


n=int(input())
s=input()
i=0
b=[]
j=0
chsl=0
while i < len(s):
    if s[i]==' ':
        b.append(chsl)
        l=1
        j+=1
        chsl=0
    else :
        if int(s[i])!=0:
            chsl=chsl*10+int(s[i])
        else:
            chsl=chsl*10
    i+=1
b.append(chsl)
b.sort()
if int(b[n-1])==int(b[n]) :
    print('NO')
else:
    print('YES')


n=int(input())
#k=[]
k=input().split()
i=0
k.sort()
if int(k[n])>int(k[n-1]):
    print('YES')
else:
    print('NO')


n=int(input())
k=[]
i=0
while i < 2*n:
    k.append(int(input()))
    i=i+1
i=0
k.sort()
if k[n]>k[n-1]:
    print('YES')
else:
    print('NO')


n=int(input())
s=input()
i=0
b=[]
j=0
l=1
chsl=0
while i < len(s):
    if s[i]==' ':
        b.append(chsl)
        l=1
        j+=1
        chsl=0
    else :
        if int(s[i])!=0:
            chsl=chsl+int(s[i])*l
        else:
            chsl=chsl*10
        l=l*10
    i+=1
b.append(chsl)
b.sort()
if int(b[n-1])==int(b[n]) :
    print('NO')
else:
    print('YES')


n= int(input())
l= [int(i) for i in input().split()]
l.sort()
if(l[n] > l[n-1]):
    print('YES')
else: print('NO')


n= int(input())
l= [int(i) for i in input().split()]
l.sort()
if(l[n-1] > l[n]):
    print('YES')
else: print('NO')


n = int(input())
arr = []

arr = [int(x) for x in input().split()]

arr.sort()

if (arr[n]==arr[n-1]):
	print("NO")
else:
	print("YES")


n = int(input())
arr = []
for e in input():
	if e is not " ":
		arr.append(int(e))
arr.sort()
if (arr[n]==arr[n-1]):
	print("NO")
else:
	print("YES")


n = int(input())
arr = []
for e in input():
	if e is not " ":
		arr.append(int(e))
arr.sort()
if (arr[n]<=arr[n-1]):
	print("NO")
else:
	print("YES")


#import os
n=int(input())
nums=map(int,input().split(" "))
nums=list(nums)
nums.sort()
if nums[n//2] == nums[n//2-1]:
    print("NO")
else:
    print("YES")


#import os
n=int(input())
nums=map(int,input().split(" "))
nums=list(nums)
nums.sort()
if nums[n] == nums[n-1]:
    print("NO")
else:
    print("YES")


n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[n - 1] < a[n]:
    print("YES")
else:
    print("NO")


# n = int(input())
# a = list(map(int, input().split()))
# a.sort()
# if a[n - 1] < a[n]:
#     print("YES")
# else:
#     print("NO")

n = int(input())
a = list(map(int, input().split()))
sorted_list = sorted(a,reverse=True)
print(sorted_list)
team1 = sorted_list[:n//2]
print(team1)
team2 = sorted_list[n//2:]
print(team2)
for i in range(n):
    if(team1[i]==team2[i]):
        print("NO")
        break
    else:
        print("YES")
        break

# import sys
#
# def is_possible(n, ratings_list):
#     sorted_ratings_list = sorted(ratings_list, reverse=True)
#
#     team1 = sorted_ratings_list[:n]
#     print(team1)
#     team2 = sorted_ratings_list[n:]
#     print(team1[-1])
#     print(team2)
#     if team1[-1] in team2:
#         return "NO"
#     else:
#         return "YES"
#
# def main():
#     n = int(sys.stdin.readline().strip())
#     ratings_list = list(map(int, sys.stdin.readline().rstrip('\n').split(' ')))
#     print(is_possible(n, ratings_list))
#
# if __name__ == '__main__':
#     main()


# n = int(input())
# b1 = list(map(int, input().split()))
# b1.sort()
# countn = 0
# county = 0
# # for i in range(len(b1)):
# if(b1[n]>b1[n-1]):
#     print("NO")
#         # countn+=1
# else:
#         # print("YES")
#         # county+=1
# # if(county==(len(b1))//2):
#         print("YES")
# # else:
# #     print("NO")

n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[n - 1] < a[n]:
    print("YES")
else:
    print("NO")


# n = int(input())
# a = list(map(int, input().split()))
# a.sort()
# if a[n - 1] < a[n]:
#     print("YES")
# else:
#     print("NO")

n = int(input())
a = list(map(int, input().split()))
sorted_list = sorted(a,reverse=True)
print(sorted_list)
team1 = sorted_list[:n//2]
# print(team1)
team2 = sorted_list[n//2:]
# print(team2)
for i in range(n):
    if(team1[i]==team2[i]):
        print("NO")
        break
    else:
        print("YES")
        break

# import sys
#
# def is_possible(n, ratings_list):
#     sorted_ratings_list = sorted(ratings_list, reverse=True)
#
#     team1 = sorted_ratings_list[:n]
#     print(team1)
#     team2 = sorted_ratings_list[n:]
#     print(team1[-1])
#     print(team2)
#     if team1[-1] in team2:
#         return "NO"
#     else:
#         return "YES"
#
# def main():
#     n = int(sys.stdin.readline().strip())
#     ratings_list = list(map(int, sys.stdin.readline().rstrip('\n').split(' ')))
#     print(is_possible(n, ratings_list))
#
# if __name__ == '__main__':
#     main()


# n = int(input())
# a = list(map(int, input().split()))
# a.sort()
# if a[n - 1] < a[n]:
#     print("YES")
# else:
#     print("NO")

n = int(input())
a = list(map(int, input().split()))
sorted_list = sorted(a,reverse=True)
# print(sorted_list)
team1 = sorted_list[:n//2]
# print(team1)
team2 = sorted_list[n//2:]
# print(team2)
for i in range(n):
    if(team1[i]==team2[i]):
        print("NO")
        break
    else:
        print("YES")
        break

# import sys
#
# def is_possible(n, ratings_list):
#     sorted_ratings_list = sorted(ratings_list, reverse=True)
#
#     team1 = sorted_ratings_list[:n]
#     print(team1)
#     team2 = sorted_ratings_list[n:]
#     print(team1[-1])
#     print(team2)
#     if team1[-1] in team2:
#         return "NO"
#     else:
#         return "YES"
#
# def main():
#     n = int(sys.stdin.readline().strip())
#     ratings_list = list(map(int, sys.stdin.readline().rstrip('\n').split(' ')))
#     print(is_possible(n, ratings_list))
#
# if __name__ == '__main__':
#     main()


# n = int(input())
# a = list(map(int, input().split()))
# a.sort()
# if a[n - 1] < a[n]:
#     print("YES")
# else:
#     print("NO")

n = int(input())
a = list(map(int, input().split()))
sorted_list = sorted(a,reverse=True)
# print(sorted_list)
team1 = sorted_list[:n]
# print(team1)
team2 = sorted_list[n:]
# print(team2)
# for i in range(n):
if team1[-1] in team2:
        print("NO")
else:
        print("YES")

# import sys
#
# def is_possible(n, ratings_list):
#     sorted_ratings_list = sorted(ratings_list, reverse=True)
#
#     team1 = sorted_ratings_list[:n]
#     print(team1)
#     team2 = sorted_ratings_list[n:]
#     print(team1[-1])
#     print(team2)
#     if team1[-1] in team2:
#         return "NO"
#     else:
#         return "YES"
#
# def main():
#     n = int(sys.stdin.readline().strip())
#     ratings_list = list(map(int, sys.stdin.readline().rstrip('\n').split(' ')))
#     print(is_possible(n, ratings_list))
#
# if __name__ == '__main__':
#     main()


n = int(input())
b1 = list(map(int, input().split()))
# b1.sort()
countn = 0
county = 0
for i in range(len(b1)):
    if(b1[i]>b1[i-1]):
        # print("NO")
        countn+=1
    else:
        # print("YES")
        county+=1
if(county==(len(b1))//2):
    print("YES")
else:
    print("NO")


n=int(input())
c=input().split(' ')
for i in range(len(c)):
    for j in range(len(c)-i-1):
        if (int(c[j])<int(c[j+1])):
            t=c[j]
            c[j]=c[j+1]
            c[j+1]=t
if (c[n-1]==c[n]):
    print('NO')
else:
    print('YES')


n=int(input())
c=input().split(' ')
for i in range(len(c)):
    for j in range(i, len(c)-i-1):
        if (int(c[i])<int(c[i+1])):
            t=c[i]
            c[i]=c[i+1]
            c[i+1]=t

if (c[n-1]==c[n]):
    print('NO')
else:
    print('YES')


n = int(input())
a = sorted(list(map(int, input().split())))[::-1]
for i in range(n):
    if a[i] < a[i + n]:
        print ('NO')
        exit()
print ('YES')


n = int(input())
a = sorted(list(map(int, input().split())))[::-1]
for i in range(n):
    if a[i] <= a[i + n]:
        print ('NO')
        exit()
print ('YES')


n = int(input())
a = sorted(list(map(int, input().split())))[::-1]
a[n:] = sorted(a[n:])
for i in range(n):
    if a[i] <= a[i + n]:
        print ('NO')
        exit()
print ('YES')


import sys

n = int(input())
arr = list(map(int,input().split()))

first = second = 0

for i in range(0,n*2,2):
    if arr[i] >= arr[i+1]:
        first += arr[i]
        second += arr[i+1]
    else:
        first += arr[i+1]
        second += arr[i]

if first > second:
    print('YES')
else:
    print('NO')


import sys

n = int(input())
arr = sorted(list(map(int,input().split())))

m = n
p = 0
for i in range(0,n):
    if arr[i] >= arr[m]:
        p = 1
        break
    m += 1
if p == 0:
    print('YES')
else:
    print('NO')


import sys
n = int(input())
a = sorted(list(map(int, input().split())))

if a[n - 1] < a[n]:
    print('YES')
else:
    print('NO')


import sys

n = int(input())
arr = list(map(int,input().split()))

s = set(arr)

if len(s) == n*2:
    print('YES')
else:
    print('NO')


n=int(input())
l=list(map(int,input().split()))
l=sorted(l)
print(l)
print(n/2)
if (l[n-1]<l[n]):
    print("YES")
else:
    print("NO")


n=int(input())
l=list(map(int,input().split()))
l=sorted(l)
if (l[n-1]<l[n]):
    print("YES")
else:
    print("NO")


n = int(input())
lst = input().split()
for i in range(n*2):
    lst[i] = int(lst[i])
lst.sort()
k = 0
for i in range(n):
    if lst[n]>lst[i]:
        k +=1
if k == n:
    print('YES')
else:
    print('NO')


n = int(input())
lst = input().split()
for i in range(n*2):
    lst[i] = int(lst[i])
#print(lst)
lst.sort()
k = 0
for i in range(n,n*2):
    for j in range(n):
        if lst[i]>lst[j]:
            #print(lst[i],lst[j])
            k +=1
            continue
if k >= n:
    print('YES')
else:
    print('NO')


n = int(input())
lst = input().split()
for i in range(n*2):
    lst[i] = int(lst[i])
#print(lst)
lst.sort()
lst_1 = lst[n:n*2]
sum_1 = sum(lst_1)
sum_2 = sum(lst[:n])
if sum_1 > sum_2:
    print('YES')
else:
    print('NO')


a = int(input())
b = sorted(list(map(int,input().split())))
print('YES' if b[a - 1] < b[a] else 'NO')


a = int(input())
b = sorted(list(map(int,input().split())))
print('YES' if b[a - 2] < b[a - 1] else 'NO')


n=int(input())
a=[int(x) for x in input().split()]
arr=[]
bbb=[]
m=n*2
i=0
while(i<=m-1):
    arr.append(a[i])
    bbb.append(a[i+1])
    i+=2
s1=0
s2=0
for i in range(n):
    s1+=max(arr[i],bbb[i])
    s2+=min(arr[i],bbb[i])
#print(s1,s2)
if(s1>s2):
    print("YES")
else:
    print("NO")


n = int(input())
ar = sorted(map(int, input().split()))
#print(ar)
#print(ar[n-1],ar[n])
if ar[n-1]==ar[n]:
    print("NO")
else:
    print("YES")