#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <queue>
#include <deque>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define LL long long
#define Pair pair<int,int>
#define LOWBIT(x) x & (-x)
using namespace std;

const int MOD=1e9+7;
const int INF=0x7ffffff;
const int magic=348;

int n;
LL x,y,p;
bool f[1000048];
LL prime[1000048],top=0;

int main ()
{
	scanf("%d",&n);
	int i,j;
	memset(f,true,sizeof(f));
	for (i=2;i<=1000000;i++)
		if (f[i])
		{
			prime[++top]=i;
			for (j=i*2;j<=1000000;j+=i)
				f[j]=false;
		}
	//cout<<top<<endl;
	//for (i=1;i<=top;i++) cout<<prime[i]<<endl;
	LL fst,snd;
	while (n--)
	{
		cin>>x>>y;
		p=x*y;
		bool t=false;
		LL l=1,r=1000000,mid;
		while (l<=r)
		{
			mid=(l+r)>>1;
			if (mid*mid*mid==p)
			{
				t=true;
				break;
			}
			if (mid*mid*mid<p) l=mid+1; else r=mid-1;
		}
		if (!t)
		{
			printf("No\n");
			continue;
		}
		//cout<<mid<<endl;
		int k=1;bool superf=true;
		//cout<<mid<<endl;
		//cout<<x<<' '<<y<<endl;
		while (mid!=1)
		{
			bool pp=true;
			while (mid%prime[k]!=0)
			{
				k++;
				if (prime[k]*prime[k]>mid)
				{
					pp=false;
					break;
				}
			}
			if (pp) while (mid%prime[k]==0) mid/=prime[k];
			LL cnt1=0,cnt2=0,ss;
			if (pp) ss=prime[k];
			else
			{
				ss=mid;
				mid=1;
			}
			while (x%ss==0)
			{
				x/=ss;
				cnt1++;
			}
			while (y%ss==0)
			{
				y/=ss;
				cnt2++;
			}
			if (cnt1>cnt2) swap(cnt1,cnt2);
			if (cnt2-cnt1>cnt1)
			{
				superf=false;
				break;
			}
				/*fst=prime[k];snd=prime[k]*prime[k];//cout<<x<<' '<<y<<endl;
				//cout<<fst<<' '<<snd<<endl;
				//cout<<x<<' '<<y<<endl;
				if (x%fst==0 && y%snd==0)
				{
					x/=fst;y/=snd;
					continue;
				}
				if (x%snd==0 && y%fst==0)
				{
					x/=snd;y/=fst;
					continue;
				}
				superf=false;
				//cout<<superf<<endl;
				break;*/
			if (!superf) break;
		}
		if (superf) printf("Yes\n"); else printf("No\n");
	}
	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <queue>
#include <deque>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define LL long long
#define Pair pair<int,int>
#define LOWBIT(x) x & (-x)
using namespace std;

const int MOD=1e9+7;
const int INF=0x7ffffff;
const int magic=348;

int n;
LL x,y,p;
bool f[1000048];
LL prime[1000048],top=0;

int main ()
{
	scanf("%d",&n);
	int i,j;
	memset(f,true,sizeof(f));
	f[1]=false;
	for (i=2;i<=1000000;i++)
		if (f[i])
		{
			prime[++top]=i;
			for (j=i*2;j<=1000000;j+=i)
				f[j]=false;
		}
	//cout<<prime[top]<<endl;
	//cout<<top<<endl;
	//for (i=1;i<=top;i++) cout<<prime[i]<<endl;
	LL fst,snd;
	LL cnt1,cnt2,ss;
	while (n--)
	{
		cin>>x>>y;
		p=x*y;
		bool t=false;
		LL l=1,r=1000000,mid;
		while (l<=r)
		{
			mid=(l+r)>>1;
			if (mid*mid*mid==p)
			{
				t=true;
				break;
			}
			if (mid*mid*mid<p) l=mid+1; else r=mid-1;
		}
		if (!t)
		{
			printf("No\n");
			continue;
		}
		//cout<<mid<<endl;
		int k=1;bool superf=true;
		//cout<<mid<<endl;
		//cout<<x<<' '<<y<<endl;
		while (mid!=1)
		{
			bool pp=true;
			if (f[mid])
			{
				LL cnt1=0,cnt2=0,ss;
				if (pp) ss=prime[k];
				else
				{
					ss=mid;
					mid=1;
				}
				while (x%ss==0)
				{
					x/=ss;
					cnt1++;
				}
				while (y%ss==0)
				{
					y/=ss;
					cnt2++;
				}
				if (cnt1>cnt2) swap(cnt1,cnt2);
				if (cnt2-cnt1>cnt1)
				{
					superf=false;
					break;
				}
				break;
			}
			while (mid%prime[k]!=0)
			{
				k++;
			}
			while (mid%prime[k]==0) mid/=prime[k];
			cnt1=0;cnt2=0;
			ss=prime[k];
			while (x%ss==0)
			{
				x/=ss;
				cnt1++;
			}
			while (y%ss==0)
			{
				y/=ss;
				cnt2++;
			}
			if (cnt1>cnt2) swap(cnt1,cnt2);
			if (cnt2-cnt1>cnt1)
			{
				superf=false;
				break;
			}
				/*fst=prime[k];snd=prime[k]*prime[k];//cout<<x<<' '<<y<<endl;
				//cout<<fst<<' '<<snd<<endl;
				//cout<<x<<' '<<y<<endl;
				if (x%fst==0 && y%snd==0)
				{
					x/=fst;y/=snd;
					continue;
				}
				if (x%snd==0 && y%fst==0)
				{
					x/=snd;y/=fst;
					continue;
				}
				superf=false;
				//cout<<superf<<endl;
				break;*/
			if (!superf) break;
		}
		if (superf) printf("Yes\n"); else printf("No\n");
	}
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <set>
#include <queue>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;

int n;

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		float a, b;
		scanf("%f%f", &a, &b);
		float c = a * b;
		float p = pow(c, 1.0 / 3.0);
		float t = ceil(pow(c, 1.0 / 3.0));
		if(p == t) printf("YES\n");
		else printf("NO\n");
	}
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <set>
#include <queue>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;

int n;

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		LL a, b;
		scanf("%I64d%I64d", &a, &b);
		LL c = a * b;
		LL l = 1LL, r = 1000000LL, ans, mid;
		while(l <= r) {
			LL mid = (l + r) >> 1;
			if(mid * mid * mid <= c) ans = mid, l = mid + 1;
			else r = mid - 1;
		}
		if(ans * ans * ans == c) printf("Yes\n");
		else printf("No\n");
	}
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <set>
#include <queue>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;

int n;

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		DB a, b;
		scanf("%lf%lfd", &a, &b);
		DB c = a * b;
		DB p = pow(c, 1.0 / 3.0);
		DB t = floor(pow(c, 1.0 / 3.0));
		if(p == t) printf("YES\n");
		else printf("NO\n");
	}
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <set>
#include <queue>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;

const DB eps = 1e-10;
int n;

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		DB a, b;
		scanf("%lf%lf", &a, &b);
		DB c = a * b;
		DB p = pow(c, 1.0 / 3.0);
		DB t = ceil(pow(c, 1.0 / 3.0));
		if(fabs(p - t) < eps) printf("Yes\n");
		else printf("No\n");
	}
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <set>
#include <queue>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;

const DB eps = 1e-10;
int n;

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		LL a, b;
		scanf("%I64d%I64d", &a, &b);
		if((a * a) % b == 0 && (b * b) % a == 0) printf("Yes\n");
		else printf("No\n");
	}
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <set>
#include <queue>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;

int n;

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		LL a, b;
		scanf("%I64d%I64d", &a, &b);
		LL c = a * b;
		DB p = pow((DB)c, 1.0 / 3.0);
		LL t = (LL)p;
		if(t * t * t == p) printf("YES\n");
		else printf("NO\n");
	}
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <set>
#include <queue>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;

const DB eps = 1e-10;
int n;

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		DB a, b;
		scanf("%lf%lf", &a, &b);
		DB c = a * b;
		DB p = pow(c, 1.0 / 3.0);
		DB t = ceil(pow(c, 1.0 / 3.0));
		if(fabs(p - t) < eps) printf("YES\n");
		else printf("NO\n");
	}
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <set>
#include <queue>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;

int n;

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		LL a, b;
		scanf("%I64d%I64d", &a, &b);
		LL c = a * b;
		LL l = 0LL, r = 1000000LL, ans, mid;
		while(l <= r) {
			LL mid = (l + r) >> 1;
			if(mid * mid * mid <= c) ans = mid, l = mid + 1;
			else r = mid - 1;
		}
		if(ans * ans * ans == c && a % ans == 0 && b % ans == 0) printf("Yes\n");
		else printf("No\n");
	}
}


#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

#define MAX 100005
#define MAXC 1000005

int n, a, b, v[MAX];

bool game(int x, int y)
{
    long long ab3 = (long long)x * y;
    bool gasit = false;
    long long st = 1, dr = MAXC, ab;
    /*while(st <= dr and !gasit)
    {
        long long m = (st + dr) / 2;
        long long mmm = m * m * m;
        if(mmm < ab3)
        {
            st = m + 1;
        }
        else
        if(mmm > ab3)
        {
            dr = m - 1;
        }
        else
        {
            ab = m;
            gasit = true;
        }
    }
    */
    long long rad = pow(ab3, 1.0 / 3);
    for(long long i = rad - 1; i <= rad + 1 and !gasit; ++i)
    {
        if(ab3 == i * i * i)
        {
            ab = i;
            gasit = true;
        }
    }
    return (gasit and a % ab == 0 and b % ab == 0);
}

int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i)
    {
        scanf("%d %d", &a, &b);
        if(game(a, b))
        {
            puts("Yes");
        }
        else
        {
            puts("No");
        }
    }
    return 0;
}


#include <iostream>
using namespace std;

#define MAX 100005
#define MAXC 1000005

int n, a, b, v[MAX];

bool game(int x, int y)
{
    long long ab3 = (long long)(x * y);
    bool gasit = false;
    long long st = 1, dr = MAXC, ab;
    for(int i = 1; i <= MAXC and !gasit; ++i)
    {
        if(i * i * i == ab3)
        {
            ab = i;
            gasit = true;
        }
    }
    return (gasit and a % ab == 0 and b % ab == 0);
}

int main()
{
    cin.sync_with_stdio(false);
    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        cin >> a >> b;
        if(game(a, b))
        {
            cout << "Yes" << '\n';
        }
        else
        {
            cout << "No" << '\n';
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

#define MAX 100005
#define MAXC 1000005

int n, a, b, v[MAX];

bool game(int x, int y)
{
    long long ab3 = (long long)x * y;
    bool gasit = false;
    long long st = 1, dr = MAXC, ab;
    while(st <= dr and !gasit)
    {
        long long m = (st + dr) / 2;
        long long mmm = m * m * m;
        if(mmm < ab3)
        {
            st = m + 1;
        }
        else
        if(mmm > ab3)
        {
            dr = m - 1;
        }
        else
        {
            ab = m;
            gasit = true;
        }
    }
    return (gasit and a % ab == 0 and b % ab == 0);
}

int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i)
    {
        scanf("%d %d", &a, &b);
        if(game(a, b))
        {
            puts("Yes");
        }
        else
        {
            puts("No");
        }
    }
    return 0;
}


#include <iostream>
#include <cmath>
using namespace std;

#define MAX 100005
#define MAXC 1000005

int n, a, b, v[MAX];

bool game(int x, int y)
{
    long long ab3 = (long long)x * y;
    bool gasit = false;
    long long st = 1, dr = MAXC, ab;
    /*while(st <= dr and !gasit)
    {
        long long m = (st + dr) / 2;
        long long mmm = m * m * m;
        if(mmm < ab3)
        {
            st = m + 1;
        }
        else
        if(mmm > ab3)
        {
            dr = m - 1;
        }
        else
        {
            ab = m;
            gasit = true;
        }
    }
    */
    long long rad = pow(ab3, 1.0 / 3);
    for(long long i = rad - 1; i <= rad + 1 and !gasit; ++i)
    {
        if(ab3 == i * i * i)
        {
            ab = i;
            gasit = true;
        }
    }
    return (gasit and a % ab == 0 and b % ab == 0);
}

int main()
{
    cin.sync_with_stdio(false);
    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        cin >> a >> b;
        if(game(a, b))
        {
            cout << "Yes" << '\n';
        }
        else
        {
            cout << "No" << '\n';
        }
    }
    return 0;
}


#include <iostream>
using namespace std;

int n, a, b;

bool game(int x, int y)
{
   for(int i = 2; i * i <= x; ++i)
   {
       int ex = 0;
       while(x % i == 0)
       {
           ex++;
           x /= i;
       }
       int ey = 0;
       while(y % i == 0)
       {
           ey++;
           y /= i;
       }
       if(ex < ey)
       {
           swap(ex, ey);
       }
       if((ex + ey) % 3 != 0 or ex > 2 * ey)
       {
           return false;
       }
   }
   if(x == 1 and y == 1)
   {
       return true;
   }
   else
   if(x > 1 and y == (long long)x * x)
   {
       return true;
   }
   else
   {
       return false;
   }
}

int main()
{
    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        cin >> a >> b;
        if(game(a, b))
        {
            cout << "Yes" << '\n';
        }
        else
        {
            cout << "No" << '\n';
        }
    }
    return 0;
}


#include <iostream>
using namespace std;

#define MAX 100005
#define MAXC 1000005

int n, a, b, v[MAX];

bool game(int x, int y)
{
    long long ab3 = (long long)x * y;
    bool gasit = false;
    long long st = 1, dr = MAXC, ab;
    while(st <= dr and !gasit)
    {
        long long m = (st + dr) / 2;
        if(m * m * m < ab3)
        {
            st = m + 1;
        }
        if(m * m * m > ab3)
        {
            dr = m - 1;
        }
        if(m * m * m == ab3)
        {
            ab = m;
            gasit = true;
        }
    }
    return (gasit and a % ab == 0 and b % ab == 0);
}

int main()
{
    cin.sync_with_stdio(false);
    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        cin >> a >> b;
        if(game(a, b))
        {
            cout << "Yes" << '\n';
        }
        else
        {
            cout << "No" << '\n';
        }
    }
    return 0;
}


#include <iostream>
using namespace std;

#define MAX 100005
#define MAXC 1000005

int n, a, b, v[MAX];

bool game(int x, int y)
{
    long long ab3 = (long long)x * y;
    bool gasit = false;
    long long st = 1, dr = MAXC, ab;
    while(st <= dr and !gasit)
    {
        long long m = (st + dr) / 2;
        long long mmm = m * m * m;
        if(mmm < ab3)
        {
            st = m + 1;
        }
        else
        if(mmm > ab3)
        {
            dr = m - 1;
        }
        else
        {
            ab = m;
            gasit = true;
        }
    }
    return (gasit and a % ab == 0 and b % ab == 0);
}

int main()
{
    cin.sync_with_stdio(false);
    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        cin >> a >> b;
        if(game(a, b))
        {
            cout << "Yes" << '\n';
        }
        else
        {
            cout << "No" << '\n';
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

#define MAX 100005
#define MAXC 1000005

int n, a, b, v[MAX];

bool game(int x, int y)
{
    long long ab3 = (long long)x * y;
    bool gasit = false;
    long long st = 1, dr = MAXC, ab;
    /*while(st <= dr and !gasit)
    {
        long long m = (st + dr) / 2;
        long long mmm = m * m * m;
        if(mmm < ab3)
        {
            st = m + 1;
        }
        else
        if(mmm > ab3)
        {
            dr = m - 1;
        }
        else
        {
            ab = m;
            gasit = true;
        }
    }
    */
    long long rad = pow(ab3, 1.0 / 3);
    for(long long i = rad - 1; i <= rad + 1 and !gasit; ++i)
    {
        if(ab3 == i * i * i)
        {
            ab = i;
            gasit = true;
        }
    }
    return (gasit and a % ab == 0 and b % ab == 0);
}

int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i)
    {
        scanf("%I64d %I64d", &a, &b);
        if(game(a, b))
        {
            puts("Yes");
        }
        else
        {
            puts("No");
        }
    }
    return 0;
}


#include <iostream>
using namespace std;

int n, a, b;

bool game(int x, int y)
{
   for(int i = 2; i * i <= x; ++i)
   {
       if(x % i == 0)
       {
           int ex = 0;
           while(x % i == 0)
           {
               ex++;
               x /= i;
           }
           int ey = 0;
           while(y % i == 0)
           {
               ey++;
               y /= i;
           }
           if(ex < ey)
           {
               swap(ex, ey);
           }
           if((ex + ey) % 3 != 0 or ex > 2 * ey)
           {
               return false;
           }
       }
   }
   if(x == 1 and y == 1)
   {
       return true;
   }
   else
   if(x > 1 and y == (long long)x * x)
   {
       return true;
   }
   else
   {
       return false;
   }
}

int main()
{
    cin.sync_with_stdio(false);
    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        cin >> a >> b;
        if(game(a, b))
        {
            cout << "Yes" << '\n';
        }
        else
        {
            cout << "No" << '\n';
        }
    }
    return 0;
}


#include <iostream>
using namespace std;

#define MAX 100005

int n, a, b, v[MAX], k;
bool prim[MAX];

void ciur()
{
    for(int i = 2; i < MAX; ++i)
    {
        prim[i] = true;
    }
    for(int i = 2; i < MAX; ++i)
    {
        if(prim[i])
        {
            int p = i + i;
            while(p < MAX)
            {
                prim[p] = false;
                p += i;
            }
        }
    }
    for(int i = 2; i < MAX; ++i)
    {
        if(prim[i])
        {
            v[++k] = i;
        }
    }
}

bool game(int x, int y)
{
    for(int i = 1; i <= k and v[i] * v[i] <= x; ++i)
    {
        if(x % v[i] == 0)
        {
           int ex = 0;
           while(x % v[i] == 0)
           {
               ex++;
               x /= v[i];
           }
           int ey = 0;
           while(y % v[i] == 0)
           {
               ey++;
               y /= v[i];
           }
           if(ex < ey)
           {
               swap(ex, ey);
           }
           if((ex + ey) % 3 != 0 or ex > 2 * ey)
           {
               return false;
           }
       }
   }
   if(x == 1 and y == 1)
   {
       return true;
   }
   else
   if(x > 1 and y == (long long)x * x)
   {
       return true;
   }
   else
   {
       return false;
   }
}

int main()
{
    k = 0;
    ciur();
    cin.sync_with_stdio(false);
    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        cin >> a >> b;
        if(game(a, b))
        {
            cout << "Yes" << '\n';
        }
        else
        {
            cout << "No" << '\n';
        }
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int n,l=0;
long long a,b,c=0,p;
bool f(int h,int t);

int main()
{
	int i,j,k=0;

	scanf("%d",&n);

	for(i=1; i<=n; ++i)
{
	scanf("%I64d %I64d",&a,&b);

	c=a*b;

	if(f(0,1000000)) printf("Yes"); else printf("No");
	printf("\n");
}

return 0;
}
bool f(int h,int t)
{
	long long i,j,k=0;

	while(h!=t)
{
	k=h+t;

	k/=2;

	k=k*k*k;

	if(k<c) h=(h+t)/2+1; else t=(h+t)/2;
}
	k=1;
	k*=h;
	k*=k*k;
	if(k==c) return true; else return false;
}


#include<bits/stdc++.h>

using namespace std;

int n,l=0;
long long a,b,c=0,p;
bool f(long long h,long long t);

int main()
{
	int i,j,k=0;

	scanf("%d",&n);

	for(i=1; i<=n; ++i)
{
	scanf("%I64d %I64d",&a,&b);

	c=a*b;

	if(f(0,1000001)) printf("Yes"); else printf("No");
	printf("\n");
}

return 0;
}
bool f(long long h,long long  t)
{
	long long i,j,k=0;

	while(h!=t)
{
	k=h+t;

	k/=2;

	if(k*k*k<c) h=k+1; else t=k;
}
	k=h*h*h;
	if(k==c) return true; else return false;
}


#include<bits/stdc++.h>

using namespace std;

int n,l=0;
long long a,b,c=0,p;
bool f(long long h,long long t);

int main()
{
	int i,j,k=0;

	scanf("%d",&n);

	for(i=1; i<=n; ++i)
{
	scanf("%I64d %I64d",&a,&b);

	c=a*b;

	if(f(0,1000000)) printf("Yes"); else printf("No");
	printf("\n");
}

return 0;
}
bool f(long long h,long long  t)
{
	long long i,j,k=0;

	while(h!=t)
{
//	printf("%d %d\n",h,t);
	k=h+t;
	k/=2;

	k=k*k*k;
//	printf("k=%I64d\n",k);

	if(k<c) h=(h+t)/2+1; else t=(h+t)/2;
}
//	if(h==t) printf("afdja;fl");
	k=1;
	k*=h;
	k*=k*k;
	if(k==c) return true; else return false;
}


#include<bits/stdc++.h>

using namespace std;

int n,l=0;
long long a,b,c=0,p;
bool f(int h,int t);

int main()
{
	int i,j,k=0;

	scanf("%d",&n);

	for(i=1; i<=n; ++i)
{
	scanf("%I64d %I64d",&a,&b);

	c=a*b;

	if(f(0,1000000)) printf("Yes"); else printf("No");
}

return 0;
}
bool f(int h,int t)
{
	long long i,j,k=0;

	while(h!=t)
{
	k=h+t;

	k/=2;

	k=k*k*k;

	if(k<c) h=(h+t)/2+1; else t=(h+t)/2;
}
	k=1;
	k*=h;
	k*=k*k;
	if(k==c) return true; else return false;
}


#include<bits/stdc++.h>

using namespace std;

int n,l=0;
long long a,b,c=0,p;
bool f(long long h,long long t);

int main()
{
	int i,j,k=0;

	scanf("%d",&n);

	for(i=1; i<=n; ++i)
{
	scanf("%I64d %I64d",&a,&b);

	c=a*b;

	if(f(0,1000001)) printf("Yes"); else printf("No");
	printf("\n");
}

return 0;
}
bool f(long long h,long long  t)
{
	long long i,j,k=0;

	while(h!=t)
{
	k=h+t;

	k/=2;

	if(k*k*k<c) h=k+1; else t=k;
}

	if(h*h*h==c) ; else return false;
	if(a%h==0 && b%h==0) return true;
	return false;
}


#include<bits/stdc++.h>

using namespace std;

int n,l=0;
long long a,b,c=0,p;
bool f(long long h,long long t);

int main()
{
	int i,j,k=0;

	scanf("%d",&n);

	for(i=1; i<=n; ++i)
{
	scanf("%I64d %I64d",&a,&b);

	c=a*b;

	if(f(0,1000001)) printf("Yes"); else printf("No");
	printf("\n");
}

return 0;
}
bool f(long long h,long long  t)
{
	long long i,j,k=0;

	while(h!=t)
{
	k=h+t;

	k/=2;

	if(k*k*k<c) h=k+1; else t=k;
}
	k=h*h*h
	if(k==c) return true; else return false;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll ;

int main() {
	vector< ll > arr( 1000003 ) ;

	for( ll i = 0 ; i < arr.size() ; i++ ) arr[i] = i*i*i ;
    int n ;
    ll a, b ;
   cin >> n ;
    for( int i = 0 ; i < n ; i++ ) {

		cin >> a >> b ;
        ll val = a*b ;
		int pos = upper_bound( arr.begin() , arr.end() , val ) - arr.begin() -1 ;

		if( !(a%pos) && !(b%pos) ) cout << "Yes" << endl ;
		else cout << "No" << endl ;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll ;

int main() {
	vector< ll > arr( 1000006 ) ;

	for( ll i = 1 ; i <= arr.size() ; i++ ) arr[i] = i*i*i ;
    int n ;
    ll a, b ;
   cin >> n ;
    for( int i = 0 ; i < n ; i++ ) {

		cin >> a >> b ;
        ll val = a*b ;
		int pos = upper_bound( arr.begin() , arr.end() , val ) - arr.begin() -1 ;

		if( arr[pos] == val ) cout << "Yes" << endl ;
		else cout << "No" << endl ;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long int ll ;

int main() {
    cin.sync_with_stdio(false) ;
	vector< ll > arr( 1000003 ) ;

	for( ll i = 0 ; i < arr.size() ; i++ ) arr[i] = i*i*i ;
    int n ;
    ll a, b ;
   //cin >> n ;
   scanf("%d",&n) ;
    for( int i = 0 ; i < n ; i++ ) {

		//cin >> a >> b ;
		scanf("%lld %lld",&a, &b) ;
        ll val = a*b ;
		int pos = upper_bound( arr.begin() , arr.end() , val ) - arr.begin() -1 ;

		if( (arr[pos] == val) && !(a%pos) && !(b%pos) ) printf("Yes\n") ;//cout << "Yes" << endl ;
		else printf("No\n") ;//cout << "No" << endl ;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll ;

int main() {
	vector< ll > arr( 1000003 ) ;

	for( ll i = 0 ; i < arr.size() ; i++ ) arr[i] = i*i*i ;
    int n ;
    ll a, b ;
   cin >> n ;
    for( int i = 0 ; i < n ; i++ ) {

		cin >> a >> b ;
        ll val = a*b ;
		int pos = upper_bound( arr.begin() , arr.end() , val ) - arr.begin() -1 ;

		if( arr[pos] == val ) cout << "Yes" << endl ;
		else cout << "No" << endl ;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll ;

int main() {
    cin.sync_with_stdio(false) ;
	vector< ll > arr( 1000003 ) ;

	for( ll i = 0 ; i < arr.size() ; i++ ) arr[i] = i*i*i ;
    int n ;
    ll a, b ;
   cin >> n ;
    for( int i = 0 ; i < n ; i++ ) {

		cin >> a >> b ;
        ll val = a*b ;
		int pos = upper_bound( arr.begin() , arr.end() , val ) - arr.begin() -1 ;

		if( !(a%pos) && !(b%pos) ) cout << "Yes" << endl ;
		else cout << "No" << endl ;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll ;

int main() {
    cin.sync_with_stdio(false) ;
	vector< ll > arr( 1000003 ) ;

	for( ll i = 0 ; i < arr.size() ; i++ ) arr[i] = i*i*i ;
    int n ;
    ll a, b ;
   //cin >> n ;
   scanf("%d",&n) ;
    for( int i = 0 ; i < n ; i++ ) {

		//cin >> a >> b ;
		scanf("%lld %lld",&a, &b) ;
        ll val = a*b ;
		int pos = upper_bound( arr.begin() , arr.end() , val ) - arr.begin() -1 ;

		if( !(a%pos) && !(b%pos) ) printf("Yes\n") ;//cout << "Yes" << endl ;
		else printf("No\n") ;//cout << "No" << endl ;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll ;

int main() {
    cin.sync_with_stdio(false) ;
	vector< ll > arr( 1000003 ) ;

	for( ll i = 0 ; i < arr.size() ; i++ ) arr[i] = i*i*i ;
    int n ;
    ll a, b ;
   //cin >> n ;
   scanf("%d",&n) ;
    for( int i = 0 ; i < n ; i++ ) {

		//cin >> a >> b ;
		scanf("%lld %lld",&a, &b) ;
        ll val = a*b ;
		int pos = upper_bound( arr.begin() , arr.end() , val ) - arr.begin() -1 ;

		if( (a[pos] == val) && !(a%pos) && !(b%pos) ) printf("Yes\n") ;//cout << "Yes" << endl ;
		else printf("No\n") ;//cout << "No" << endl ;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll ;

int main() {
	vector< ll > arr( 1000003 ) ;

	for( ll i = 1 ; i < arr.size() ; i++ ) arr[i] = i*i*i ;
    int n ;
    ll a, b ;
   cin >> n ;
    for( int i = 0 ; i < n ; i++ ) {

		cin >> a >> b ;
        ll val = a*b ;
		int pos = upper_bound( arr.begin() , arr.end() , val ) - arr.begin() -1 ;

		if( arr[pos] == val ) cout << "Yes" << endl ;
		else cout << "No" << endl ;
	}

	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
//	freopen("in.txt","r",stdin);
	int n;
	long long x,y;
	scanf("%d",&n);
	while(n--){
		scanf("%I64d %I64d",&x,&y);
		long long z=x*y;
		z = (long long )(pow(z*1.0,1.0/3)+0.0000001);
		if(z*z*z==x*y && x % z==0 && y % z ==0) puts("Yes");
		else puts("No");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
const int maxn = 1<<16;
bool flag[maxn];
int prm[maxn];
int a[50],am[50],b[50],bm[50];
int main(){
//	freopen("in.txt","r",stdin);
	int totp=0;
	for(int i=2;i<maxn;i++)
		if(flag[i]==0){
			totp++;
			prm[totp]=i;
			for(int j=i;j<maxn;j+=i)
				flag[j]=1;
		}
	int n,x,y;
	cin>>n;
	while(n--){
		scanf("%d %d",&x,&y);
//		cout<<x<<y<<endl;
		memset(am,0,sizeof am);
		memset(bm,0,sizeof bm);
		memset(a,0,sizeof a);
		memset(b,0,sizeof b);
		int p=1;
		int tot1=0;
		while(x && p<=totp){
			if(x % prm[p]==0){
//				cout<<x<<"**"<<endl;
				tot1++;
				a[tot1]=prm[p];
				while(x % prm[p]==0){
//					cout<<x<<endl;
					am[tot1]++;
					x = x/prm[p];
				}
			}
			p++;
		}
		p=1;
		int tot2=0;
		while(y && p<=totp){
			if(y % prm[p]==0){
				tot2++;
				b[tot2]=prm[p];
				while(y % prm[p]==0){
					bm[tot2]++;
					y = y/prm[p];
				}
			}
			p++;
		}
//		for(int i=1;i<=tot1;i++) cout<<a[i]<<' ';cout<<endl;
//		for(int i=1;i<=tot1;i++) cout<<am[i]<<' ';cout<<endl;
//		for(int i=1;i<=tot1;i++) cout<<b[i]<<' ';cout<<endl;
//		for(int i=1;i<=tot1;i++) cout<<bm[i]<<' ';cout<<endl;cout<<endl;
		if(tot1 != tot2){
			cout<<"No"<<endl;
			continue;
		}
		int flg=0;
		for(int i=1;i<=tot1;i++){
			if(a[i]!=b[i]) {
				flg=1;
				break;
			}
		}
		if(flg) {
			cout<<"No"<<endl;
			continue;
		}
		for(int i=1;i<=tot1;i++){
			if(am[i]==bm[i] && am[i] % 3 !=0) {
				flg=1;
				break;
			}
			int x=fabs(am[i]-bm[i]);
			int minn= min(am[i],bm[i]);
			int maxx= max(am[i],bm[i]);
			minn-=x;
			maxx-=x*2;
			if(minn!=maxx || minn % 3 !=0){
				flg=1;
				break;
			}
		}
		if(flg==1){
			cout<<"No"<<endl;
			continue;
		}
		cout<<"Yes"<<endl;
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
//	freopen("in.txt","r",stdin);
	int n;
	long long x,y;
	scanf("%d",&n);
	while(n--){
		cin>>x>>y;
		long long z=x*y;
		z = (long long )(pow(z*1.0,1.0/3)+0.0000001);
		if(z*z*z==x*y && x % z==0 && y % z ==0) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
//	freopen("in.txt","r",stdin);
	int n;
	long long x,y;
	scanf("%d",&n);
	while(n--){
		cin>>x>>y;
		long long z=x*y;
		int flag=0;
		for(long long i=1;i<=2000;i++){
			if(i*i*i > z) break;
			if(i*i*i == z){
				flag=1;
				break;
			}
		}
		if(flag==0){
			cout<<"No"<<endl;
		}else{
			cout<<"Yes"<<endl;
		}
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
//	freopen("in.txt","r",stdin);
	int n;
	long long x,y;
	scanf("%d",&n);
	while(n--){
		cin>>x>>y;
		long long z=x*y;
		int flag=0;
		for(long long i=1;i<=1000000;i++){
			if(i*i*i > z) break;
			if(i*i*i == z && x % i ==0 && y % i ==0){
				flag=1;
				break;
			}
		}
		if(flag) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
//	freopen("in.txt","r",stdin);
	int n;
	long long x,y;
	scanf("%d",&n);
	while(n--){
		scanf("%I64d %I64d",&x,&y);
		long long z=x*y;
		int flag=0;
		for(long long i=1;i<=1000000;i++){
			if(i*i*i > z) break;
			if(i*i*i==z && x % i ==0 && y % i==0){
				flag=1;
				break;
			}
		}
		if(flag) puts("Yes");
		else puts("No");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
//	freopen("in.txt","r",stdin);
	int n;
	long long x,y;
	scanf("%d",&n);
	while(n--){
		cin>>x>>y;
		long long z=x*y;
		int flag=0;
		for(long long i=1;i<=1000000;i++){
			if(i*i*i > z) break;
			if(i*i*i == z){
				flag=1;
				break;
			}
		}
		if(flag==0){
			cout<<"No"<<endl;
		}else{
			cout<<"Yes"<<endl;
		}
	}
	return 0;
}


#include <stdio>
#include <fstream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <iterator>
#include <map>

using namespace std;

int main(){

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

	for (int g = 1; g <= n; g ++)
	{
		int a, b;
		scanf ("%d %d", &a, &b);

		if (a == 1 && b == 1)
		{
			puts ("Yes");
		}
		else
		if (a == 1 && b != 1)
		{
			puts ("No");

		}
		else
		if (a != 1 && b == 1)
		{
			puts ("No");

		}
		else
		{
		///////
		map <int, int> p1;
		map <int, int> p2;

		int a1 = a;
		int mx = 1;

		for (int i = 2; i * i <= a1; i ++)
		{
			if (a % i == 0)
			{
				mx = max (mx, i);
				while (a % i == 0)
				{
					a /= i;
					p1[i] ++;
					//cout << i << " ";
				}
				if (a == 1) break;
			}
			if (a == 1) break;
		}

		if (a > 1)
		{
			//cout << a;
			mx = max (mx, a);
			p1[a] ++;
		}
		//cout << endl;

		int b1 = b;
		for (int i = 2; i * i <= b1; i ++)
		{
			if (b % i == 0)
			{
				mx = max (mx, i);
				while (b % i == 0)
				{
					b /= i;
					p2[i] ++;
					//cout << i << " ";
				}
				if (b == 1) break;
			}
			if (b == 1) break;
		}

		if (b > 1)
		{
			mx = max (mx, b);
			p2[b] ++;
			//cout << b << " ";
		}
			//cout << endl;

		bool flag = true;

		for (int j = 2; j <= mx; j ++)
		{
			if (p1[j] == 0 && p2[j] == 0)
				continue;

			if (p1[j] * 2 == p2[j] || p1[j] == p2[j] * 2)
			{
				int nnnn = 0;
			}
			else
			{
				int xx = p1[j];
				int yy = p2[j];
				if (xx == 0 || yy == 0)
				{
					flag = false;
				}
				else
				{
					bool f11 = false;

					if (2 * xx - yy > 0)
					{
						if ((2 * xx - yy) % 3 == 0)
						{
							f11 = true;
						}
					}

					if (2 * yy - xx > 0)
					{
						if ((2 * yy - xx) % 3 == 0)
						{
							f11 = true;
						}
					}

					if (!f11)
						flag = false;
				}

			}

		}

		if (flag)
			puts ("Yes");
		else
			puts ("No");
		////
		}
	}

	return 0;
}


#include <iostream>
#include <fstream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <iterator>
#include <map>

using namespace std;

int main(){

	int n;
	cin >> n;

	for (int g = 1; g <= n; g ++)
	{
		int a, b;
		cin >> a >> b;

		if (a == 1 && b == 1)
		{
			cout << "Yes" << endl;
		}
		else
		if (a == 1 && b != 1)
		{
			cout << "No" << endl;

		}
		else
		if (a != 1 && b == 1)
		{
			cout << "No" << endl;

		}
		else
		{
		///////
		map <int, int> p1;
		map <int, int> p2;

		int a1 = a;
		int mx = 1;

		for (int i = 2; i * i <= a1; i ++)
		{
			if (a % i == 0)
			{
				mx = max (mx, i);
				while (a % i == 0)
				{
					a /= i;
					p1[i] ++;
					//cout << i << " ";
				}
				if (a == 1) break;
			}
			if (a == 1) break;
		}

		if (a > 1)
		{
			//cout << a;
			mx = max (mx, a);
			p1[a] ++;
		}
		//cout << endl;

		int b1 = b;
		for (int i = 2; i * i <= b1; i ++)
		{
			if (b % i == 0)
			{
				mx = max (mx, i);
				while (b % i == 0)
				{
					b /= i;
					p2[i] ++;
					//cout << i << " ";
				}
				if (b == 1) break;
			}
			if (b == 1) break;
		}

		if (b > 1)
		{
			mx = max (mx, b);
			p2[b] ++;
			//cout << b << " ";
		}
			//cout << endl;

		bool flag = true;

		for (int j = 2; j <= mx; j ++)
		{
			if (p1[j] == 0 && p2[j] == 0)
				continue;

			if (p1[j] * 2 == p2[j] || p1[j] == p2[j] * 2)
			{
				int nnnn = 0;
			}
			else
			{
				int xx = p1[j];
				int yy = p2[j];
				if (xx == 0 || yy == 0)
				{
					flag = false;
				}
				else
				{
					bool f11 = false;

					if (2 * xx - yy > 0)
					{
						if ((2 * xx - yy) % 3 == 0)
						{
							f11 = true;
						}
					}

					if (2 * yy - xx > 0)
					{
						if ((2 * yy - xx) % 3 == 0)
						{
							f11 = true;
						}
					}

					if (!f11)
						flag = false;
				}

			}

		}

		if (flag)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
		////
		}
	}

	return 0;
}


#include <iostream>
#include <fstream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <iterator>

using namespace std;

int main(){

	int n;
	cin >> n;

	for (int g = 1; g <= n; g ++)
	{
		int a, b;
		cin >> a >> b;

		if (a == 1 && b == 1)
		{
			cout << "Yes" << endl;
			continue;
		}

		vector <int> p1(32000, 0);
		vector <int> p2(32000, 0);

		int a1 = a;
		int mx = 1;

		for (int i = 2; i * i < a1; i ++)
		{
			if (a % i == 0)
			{
				mx = max (mx, a);
				while (a % i == 0)
				{
					a /= i;
					p1[i] ++;
				}
				if (a == 1) break;
			}
			if (a == 1) break;
		}

		if (a > 1)
		{
			mx = max (mx, a);
			p1[a] ++;
		}

		int b1 = b;
		for (int i = 2; i * i < b1; i ++)
		{
			if (b % i == 0)
			{
				mx = max (mx, b);
				while (b % i == 0)
				{
					b /= i;
					p2[i] ++;
				}
				if (b == 1) break;
			}
			if (b == 1) break;
		}

		if (b > 1)
		{
			mx = max (mx, b);
			p2[b] ++;
		}

		bool flag = true;

		for (int j = 2; j <= mx; j ++)
		{
			if (p1[j] * 2 == p2[j] || p1[j] == p2[j] * 2)
			{
				int nnnn = 0;
			}
			else
			if (p1[j] == p2[j])
			{
				if (p1[j] % 3 != 0)
				{
					flag = false;
					break;
				}
			}
			else
			{
				flag = false;
				break;
			}
		}

		if (flag)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}

	return 0;
}


#include <iostream>
#include <fstream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <tgmath.h>

using namespace std;

int main(){

    int n;
    cin >> n;

    for (int i = 1; i <= n; i ++)
    {
        long long a, b;
        cin >> a >> b;
        long long p = pow(a * b, 1.0 / 3.0);
        while (p * p * p < a * b)
            p ++;

        if (p * p * p != a * b)
        {
            cout << "No" << endl;
            continue;
        }
        if (a % p == 0 && b % p == 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    return 0;
}


#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <tgmath.h>

using namespace std;

int main(){

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

    for (int i = 1; i <= n; i ++)
    {
        long long a, b;
        scanf ("%I64d %I64d", &a, &b);
        long long p = pow(a * b, 1.0 / 3.0);
        while (p * p * p < a * b)
            p ++;

        if (p * p * p != a * b)
        {
            puts ("No");
            continue;
        }
        if (a % p == 0 && b % p == 0)
        {
            puts ("Yes");
        }
        else
        {
            puts ("No");
        }
    }
    return 0;
}


#include <iostream>
#include <fstream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <iterator>
#include <map>

using namespace std;

int main(){

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

	for (int g = 1; g <= n; g ++)
	{
		long long a, b;
		scanf ("%I64d %I64d", &a, &b);

		if (a == 1 && b == 1)
		{
			puts ("Yes");
		}
		else
		if (a == 1 && b != 1)
		{
			puts ("No");

		}
		else
		if (a != 1 && b == 1)
		{
			puts ("No");

		}
		else
		{
		///////
		map <int, int> p1;
		map <int, int> p2;

		int a1 = a;
		int mx = 1;

		for (int i = 2; i * i <= a1; i ++)
		{
			if (a % i == 0)
			{
				mx = max (mx, i);
				while (a % i == 0)
				{
					a /= i;
					p1[i] ++;
					//cout << i << " ";
				}
				if (a == 1) break;
			}
			if (a == 1) break;
		}

		if (a > 1)
		{
			//cout << a;
			mx = max (mx, a);
			p1[a] ++;
		}
		//cout << endl;

		int b1 = b;
		for (int i = 2; i * i <= b1; i ++)
		{
			if (b % i == 0)
			{
				mx = max (mx, i);
				while (b % i == 0)
				{
					b /= i;
					p2[i] ++;
					//cout << i << " ";
				}
				if (b == 1) break;
			}
			if (b == 1) break;
		}

		if (b > 1)
		{
			mx = max (mx, b);
			p2[b] ++;
			//cout << b << " ";
		}
			//cout << endl;

		bool flag = true;

		for (int j = 2; j <= mx; j ++)
		{
			if (p1[j] == 0 && p2[j] == 0)
				continue;

			if (p1[j] * 2 == p2[j] || p1[j] == p2[j] * 2)
			{
				int nnnn = 0;
			}
			else
			{
				int xx = p1[j];
				int yy = p2[j];
				if (xx == 0 || yy == 0)
				{
					flag = false;
				}
				else
				{
					bool f11 = false;

					if (2 * xx - yy > 0)
					{
						if ((2 * xx - yy) % 3 == 0)
						{
							f11 = true;
						}
					}

					if (2 * yy - xx > 0)
					{
						if ((2 * yy - xx) % 3 == 0)
						{
							f11 = true;
						}
					}

					if (!f11)
						flag = false;
				}

			}

		}

		if (flag)
			puts ("Yes");
		else
			puts ("No");
		////
		}
	}

	return 0;
}


#include <iostream>
#include <fstream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <tgmath.h>

using namespace std;

int main(){

    int n;
    cin >> n;

    for (int i = 1; i <= n; i ++)
    {
        long long a, b;
        cin >> a >> b;
        long long p = cbrt (a * b);
        if (p * p * p != a * b)
        {
            cout << "No" << endl;
            continue;
        }
        if (a % p == 0 && b % p == 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    return 0;
}


#include <iostream>
#include <fstream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <iterator>

using namespace std;

int main(){

	int n;
	cin >> n;

	for (int g = 1; g <= n; g ++)
	{
		int a, b;
		cin >> a >> b;

		if (a == 1 && b == 1)
		{
			cout << "Yes" << endl;
			continue;
		}

		if (a == 1 && b != 1)
		{
			cout << "No" << endl;
			continue;
		}

		if (a != 1 && b == 1)
		{
			cout << "No" << endl;
			continue;
		}

		vector <int> p1(32000, 0);
		vector <int> p2(32000, 0);

		int a1 = a;
		int mx = 1;

		for (int i = 2; i * i <= a1; i ++)
		{
			if (a % i == 0)
			{
				mx = max (mx, i);
				while (a % i == 0)
				{
					a /= i;
					p1[i] ++;
					//cout << i << " ";
				}
				if (a == 1) break;
			}
			if (a == 1) break;
		}

		if (a > 1)
		{
			//cout << a;
			mx = max (mx, a);
			p1[a] ++;
		}
		//cout << endl;

		int b1 = b;
		for (int i = 2; i * i <= b1; i ++)
		{
			if (b % i == 0)
			{
				mx = max (mx, i);
				while (b % i == 0)
				{
					b /= i;
					p2[i] ++;
					//cout << i << " ";
				}
				if (b == 1) break;
			}
			if (b == 1) break;
		}

		if (b > 1)
		{
			mx = max (mx, b);
			p2[b] ++;
			//cout << b << " ";
		}
			//cout << endl;

		bool flag = true;

		for (int j = 2; j <= mx; j ++)
		{
			if (p1[j] * 2 == p2[j] || p1[j] == p2[j] * 2)
			{
				int nnnn = 0;
			}
			else
			{
				int xx = p1[j];
				int yy = p2[j];
				if (xx == 0 || yy == 0)
				{
					flag = false;
				}
				if (2 * xx - yy > 0)
				{
					if ((2 * xx - yy) % 3 != 0)
					{
						flag = false;
						break;
					}
				}
				else
				if (2 * yy - xx > 0)
				{
					if ((2 * yy - xx) % 3 != 0)
					{
						flag = false;
						break;
					}
				}
				else
				{
					flag = false;
					break;
				}
			}
		}

		if (flag)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int prime[100005];
int idxa[31608];
int idxb[31608];
int gcd(int a, int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
void sieve()
{
    for(int i=2;i<=sqrt(1e5);i++)
    {
        if(prime[i]==0)
        {
            for(int j=i*i;j<=1e5;j+=i)
            {
                prime[j]=1;
            }
        }
    }
}
inline void printAns(bool ans)
{
    if(ans)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
}
int main()
{
    sieve();
    int n;
    scanf("%d",&n);
    int u,v;
    int i,j,k;
    long long r=1e9;
    vector<int> a;
    for(i=2;i<=1e5;i++)
    {
        long long t;
        if(prime[i]==0)
        {
            t=i;
            if(t*t<r)
            {
                a.push_back(i);
            }
            else
            {
                break;
            }
        }
    }
    for(i=0;i<n;i++)
    {
        scanf("%d%d",&u,&v);
        if(u==v && u==1)
        {
            printAns(true);
            continue;
        }
        if(gcd(u,v)==1)
        {
            printAns(false);
            continue;
        }
        bool ans=true;
        for(j=0;j<a.size();j++)
        {
            if(u%a[j]==0 && v%a[j]==0)
            {
                while(u>1 && u%a[j]==0)
                {
                    u/=a[j];
                    idxa[a[j]]++;
                }
                while(v>1 && v%a[j]==0)
                {
                    v/=a[j];
                    idxb[a[j]]++;
                }
                while(idxb[a[j]]!=0 && idxa[a[j]]!=0)
                {
                    if(idxa[a[j]]>idxb[a[j]])
                    {
                        swap(idxa[a[j]],idxb[a[j]]);
                    }
                    bool ok=false;
                    for(k=idxa[a[j]];k>0;k--)
                    {
                        if(idxb[a[j]]>=k*2)
                        {
                            idxb[a[j]]-=(k*2);
                            idxa[a[j]]-=k;
                            ok=true;
                            break;
                        }
                    }
                    if(!ok)
                    {
                        break;
                    }
                }
                if(idxa[a[j]]!=0 || idxb[a[j]]!=0)
                {
                    idxa[a[j]]=idxb[a[j]]=0;
                    ans=false;
                    break;
                }
            }
            if(u<a[j] || v<a[j])
            {
                break;
            }
        }
        if(u!=v && u!=1)
        {
            printAns(false);
        }
        else
        {
            printAns(ans);
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int prime[100005];
int idxa[31608];
int idxb[31608];
int gcd(int a, int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
void sieve()
{
    for(int i=2;i<=sqrt(1e5);i++)
    {
        if(prime[i]==0)
        {
            for(int j=i*i;j<=1e5;j+=i)
            {
                prime[j]=1;
            }
        }
    }
}
inline void printAns(bool ans)
{
    if(ans)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
}
int main()
{
    sieve();
    int n;
    scanf("%d",&n);
    int u,v;
    int i,j,k;
    long long r=1e9;
    vector<int> a;
    for(i=2;i<=1e5;i++)
    {
        long long t;
        if(prime[i]==0)
        {
            t=i;
            if(t*t<r)
            {
                a.push_back(i);
            }
            else
            {
                break;
            }
        }
    }
    for(i=0;i<n;i++)
    {
        scanf("%d%d",&u,&v);
        if(u==v && u==1)
        {
            printAns(true);
            continue;
        }
        if(gcd(u,v)==1)
        {
            printAns(false);
            continue;
        }
        bool ans=true;
        for(j=0;j<a.size();j++)
        {
            if(u%a[j]==0 && v%a[j]==0)
            {
                while(u>1 && u%a[j]==0)
                {
                    u/=a[j];
                    idxa[a[j]]++;
                }
                while(v>1 && v%a[j]==0)
                {
                    v/=a[j];
                    idxb[a[j]]++;
                }
                while(idxb[a[j]]!=0 && idxa[a[j]]!=0)
                {
                    if(idxa[a[j]]>idxb[a[j]])
                    {
                        swap(idxa[a[j]],idxb[a[j]]);
                    }
                    idxb[a[j]]-=2;
                    idxa[a[j]]--;
                    if(idxa[a[j]]<0 || idxb[a[j]]<0)
                    {
                        break;
                    }
                }
                if(idxa[a[j]]!=0 || idxb[a[j]]!=0)
                {
                    idxa[a[j]]=idxb[a[j]]=0;
                    ans=false;
                    break;
                }
            }
            if(u<a[j] || v<a[j])
            {
                break;
            }
        }
        if(u!=v && u!=1)
        {
            printAns(false);
        }
        else
        {
            printAns(ans);
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int prime[100005];
int idxa[31608];
int idxb[31608];
int gcd(int a, int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
void sieve()
{
    for(int i=2;i<=sqrt(1e5);i++)
    {
        if(prime[i]==0)
        {
            for(int j=i*i;j<=1e5;j+=i)
            {
                prime[j]=1;
            }
        }
    }
}
inline void printAns(bool ans)
{
    if(ans)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
}
int main()
{
    sieve();
    int n;
    scanf("%d",&n);
    int u,v;
    int i,j,k;
    long long r=1e9;
    vector<int> a;
    for(i=2;i<=1e5;i++)
    {
        long long t;
        if(prime[i]==0)
        {
            t=i;
            if(t*t<r)
            {
                a.push_back(i);
            }
            else
            {
                break;
            }
        }
    }
    for(i=0;i<n;i++)
    {
        scanf("%d%d",&u,&v);
        if(u==v && u==1)
        {
            printAns(true);
            continue;
        }
        if(gcd(u,v)==1)
        {
            printAns(false);
            continue;
        }
        bool ans=true;
        for(j=0;j<a.size();j++)
        {
            if(u%a[j]==0 && v%a[j]==0)
            {
                while(u>1 && u%a[j]==0)
                {
                    u/=a[j];
                    idxa[a[j]]++;
                }
                while(v>1 && v%a[j]==0)
                {
                    v/=a[j];
                    idxb[a[j]]++;
                }
                while(idxb[a[j]]!=0 && idxa[a[j]]!=0)
                {
                    if(idxa[a[j]]>idxb[a[j]])
                    {
                        swap(idxa[a[j]],idxb[a[j]]);
                    }
                    idxb[a[j]]-=2;
                    idxa[a[j]]--;
                    if(idxa[a[j]]<0 || idxb[a[j]]<0)
                    {
                        break;
                    }
                }
                if(idxa[a[j]]!=0 || idxb[a[j]]!=0)
                {
                    idxa[a[j]]=idxb[a[j]]=0;
                    ans=false;
                    break;
                }
            }
            if(u<a[j] || v<a[j])
            {
                break;
            }
        }
        if(u!=v || (u==v && u!=1))
        {
            printAns(false);
        }
        else
        {
            printAns(ans);
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int prime[100005];
int idxa[31608];
int idxb[31608];
int gcd(int a, int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
void sieve()
{
    for(int i=2;i<=sqrt(1e5);i++)
    {
        if(prime[i]==0)
        {
            for(int j=i*i;j<=1e5;j+=i)
            {
                prime[j]=1;
            }
        }
    }
}
inline void printAns(bool ans)
{
    if(ans)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
}
int main()
{
    sieve();
    int n;
    scanf("%d",&n);
    int u,v;
    int i,j,k;
    long long r=1e9;
    vector<int> a;
    for(i=2;i<=1e5;i++)
    {
        long long t;
        if(prime[i]==0)
        {
            t=i;
            if(t*t<r)
            {
                a.push_back(i);
            }
            else
            {
                break;
            }
        }
    }
    for(i=0;i<n;i++)
    {
        scanf("%d%d",&u,&v);
        if(u==v && u==1)
        {
            printAns(true);
            continue;
        }
        if(gcd(u,v)==1)
        {
            printAns(false);
            continue;
        }
        bool ans=true;
        for(j=0;j<a.size();j++)
        {
            if(u%a[j]==0 && v%a[j]==0)
            {
                while(u>1 && u%a[j]==0)
                {
                    u/=a[j];
                    idxa[a[j]]++;
                }
                while(v>1 && v%a[j]==0)
                {
                    v/=a[j];
                    idxb[a[j]]++;
                }
                while(idxb[a[j]]!=0 && idxa[a[j]]!=0)
                {
                    if(idxa[a[j]]>idxb[a[j]])
                    {
                        swap(idxa[a[j]],idxb[a[j]]);
                    }
                    bool ok=false;
                    for(k=idxa[a[j]];k>=0;k--)
                    {
                        if(idxb[a[j]]>=k*2)
                        {
                            idxb[a[j]]-=(k*2);
                            idxa[a[j]]-=k;
                            ok=true;
                            break;
                        }
                    }
                    if(!ok)
                    {
                        break;
                    }
                }
                if(idxa[a[j]]!=0 || idxb[a[j]]!=0)
                {
                    idxa[a[j]]=idxb[a[j]]=0;
                    ans=false;
                    break;
                }
            }
            if(u<a[j] || v<a[j])
            {
                break;
            }
        }
        if(u!=v && u!=1)
        {
            printAns(false);
        }
        else
        {
            printAns(ans);
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int i;
    long long u,v;
    for(i=0;i<n;i++)
    {
        scanf("%I64d%I64d",&u,&v);
        long long l,m,r;
        l=0;
        r=1e6;
        bool ok=false;
        while(l<=r)
        {
            m=(l+r)/2;
            if(m*m*m==u*v && u%m==0 && v%m==0)
            {
                ok=true;
                break;
            }
            else if(m*m*m<u*v)
            {
                l=m+1;
            }
            else
            {
                r=m-1;
            }
        }
        if(ok)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
int prime[100005];
int idxa[31608];
int idxb[31608];
int gcd(int a, int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
void sieve()
{
    for(int i=2;i<=sqrt(1e5);i++)
    {
        if(prime[i]==0)
        {
            for(int j=i*i;j<=1e5;j+=i)
            {
                prime[j]=1;
            }
        }
    }
}
inline void printAns(bool ans)
{
    if(ans)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
}
int main()
{
    sieve();
    int n;
    scanf("%d",&n);
    int u,v;
    int i,j,k;
    long long r=1e9;
    vector<int> a;
    for(i=2;i<=1e5;i++)
    {
        long long t;
        if(prime[i]==0)
        {
            t=i;
            if(t*t<r)
            {
                a.push_back(i);
            }
            else
            {
                break;
            }
        }
    }
    for(i=0;i<n;i++)
    {
        scanf("%d%d",&u,&v);
        if(u==v && u==1)
        {
            printAns(true);
            continue;
        }
        if(gcd(u,v)==1)
        {
            printAns(false);
            continue;
        }
        bool ans=true;
        for(j=0;j<a.size();j++)
        {
            if(u%a[j]==0 && v%a[j]==0)
            {
                while(u>1 && u%a[j]==0)
                {
                    u/=a[j];
                    idxa[a[j]]++;
                }
                while(v>1 && v%a[j]==0)
                {
                    v/=a[j];
                    idxb[a[j]]++;
                }
                while(idxb[a[j]]!=0 && idxa[a[j]]!=0)
                {
                    if(idxa[a[j]]>idxb[a[j]])
                    {
                        swap(idxa[a[j]],idxb[a[j]]);
                    }
                    bool ok=false;
                    for(k=idxa[a[j]];k>0;k--)
                    {
                        if(idxb[a[j]]>=k*2)
                        {
                            idxb[a[j]]-=(k*2);
                            idxa[a[j]]-=k;
                            ok=true;
                            break;
                        }
                    }
                    cout<<ok<<endl;
                    if(!ok)
                    {
                        break;
                    }
                }
                if(idxa[a[j]]!=0 || idxb[a[j]]!=0)
                {
                    idxa[a[j]]=idxb[a[j]]=0;
                    ans=false;
                    break;
                }
            }
            if(u<a[j] || v<a[j])
            {
                break;
            }
        }
        if(u!=v && u!=1)
        {
            printAns(false);
        }
        else
        {
            printAns(ans);
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int i;
    long long u,v;
    for(i=0;i<n;i++)
    {
        scanf("%I64d%I64d",&u,&v);
        long long l,m,r,k;
        l=0;
        r=1e6;
        bool ok=false;
        while(l<=r)
        {
            m=(l+r)/2;
            if(m*m*m==u*v)
            {
                ok=true;
                break;
            }
            else if(m*m*m<u*v)
            {
                l=m+1;
            }
            else
            {
                r=m-1;
            }
        }
        if(ok)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
int prime[100005];
int idxa[31608];
int idxb[31608];
map<pair<int,int>,int> M;
int gcd(int a, int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
void sieve()
{
    for(int i=2;i<=sqrt(31608);i++)
    {
        if(prime[i]==0)
        {
            for(int j=i*i;j<=31608;j+=i)
            {
                prime[j]=1;
            }
        }
    }
}
inline void printAns(bool ans)
{
    if(ans)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
}
int main()
{
    sieve();
    int n;
    scanf("%d",&n);
    int u,v;
    int i,j,k;
    long long r=1e9;
    vector<int> a;
    for(i=2;i<=1e5;i++)
    {
        long long t;
        if(prime[i]==0)
        {
            t=i;
            if(t*t<r)
            {
                a.push_back(i);
            }
            else
            {
                break;
            }
        }
    }
    for(i=0;i<n;i++)
    {
        int t1,t2;
        scanf("%d%d",&u,&v);
        t1=u;
        t2=v;
        if(u==v && u==1)
        {
            printAns(true);
            continue;
        }
        if(gcd(u,v)==1)
        {
            printAns(false);
            continue;
        }
        int e=M[make_pair(t1,t2)];
        if(e==1 || e==2)
        {
            if(e==1)
            {
                printAns(true);
            }
            else
            {
                printAns(false);
            }
            continue;
        }
        bool ans=true;
        for(j=0;j<a.size();j++)
        {
            if(u%a[j]==0 && v%a[j]==0)
            {
                while(u>1 && u%a[j]==0)
                {
                    u/=a[j];
                    idxa[a[j]]++;
                }
                while(v>1 && v%a[j]==0)
                {
                    v/=a[j];
                    idxb[a[j]]++;
                }
                while(idxb[a[j]]!=0 && idxa[a[j]]!=0)
                {
                    if(idxa[a[j]]>idxb[a[j]])
                    {
                        swap(idxa[a[j]],idxb[a[j]]);
                    }
                    idxb[a[j]]-=2;
                    idxa[a[j]]--;
                    if(idxa[a[j]]<0 || idxb[a[j]]<0)
                    {
                        break;
                    }
                }
                if(idxa[a[j]]!=0 || idxb[a[j]]!=0)
                {
                    idxa[a[j]]=idxb[a[j]]=0;
                    ans=false;
                    break;
                }
            }
            if(u<a[j] || v<a[j])
            {
                break;
            }
        }
        if(u!=v || (u==v && u!=1))
        {
            M[make_pair(t1,t2)]=2;
            M[make_pair(t2,t1)]=2;
            printAns(false);
        }
        else
        {
            M[make_pair(t1,t2)]=1;
            M[make_pair(t2,t1)]=1;
            printAns(ans);
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#define MAX 1000001

using namespace std;
typedef long long ll;

ll nrp,n,a,b,fa,fb,r;
ll cubic_root(ll nr){
  ll s=1,d=MAX,m;
  while(s<d){
    m=(s+d+1)/2;
    if(m*m*m<=nr)s=m;
    else d=m-1;
  }
  return s;
}

int main()
{
    cin.sync_with_stdio(false);
    scanf("%d", &n);
    for(ll i=1;i<=n;i++){
      scanf("%I64d %I64d", &a, &b);
      r=cubic_root(a*b);
      if(r*r*r==a*b&&a%r==0&&b%r==0)puts("Yes");
      else puts("No");
    }
    return 0;
}


#include <iostream>
#include <bitset>
#include <vector>
#define MAX 31630

using namespace std;

int nrp,n,a,b,fa,fb;
bool test;
bitset <MAX+1> prim;
vector <int> prime;
void ciur(){
  prim.set();prim[0]=prim[1]=false;
  for(int i=2;i<=MAX;i++)
    if(prim[i]) for(int j=i*i;j<=MAX;j+=i)prim[j]=false;
  for(int i=2;i<=MAX;i++)
    if(prim[i])prime.push_back(i);
}

int main()
{
    ciur();
    cin>>n;
    for(int i=1;i<=n;i++){
      cin>>a>>b;
      test=false;
      for(int j=0;(prime[j]*prime[j]<=a||prime[j]*prime[j]<=b)&&not test;j++){
        fa=fb=0;
        while(a%prime[j]==0)fa++,a/=prime[j];
        while(b%prime[j]==0)fb++,b/=prime[j];
        if((fa+fb)%3!=0||max(fa,fb)>min(fa,fb)*2)test=true;
      }
      if(test||a>1||b>1)cout<<"No\n";
      else cout<<"Yes\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long

int main()
{

   int n; cin >> n;
   int arr[n];
   for(int i=0; i<n; i++) cin >> arr[i];
   int q; cin >> q;
   vector< pair<int, int>>ans(n);
   for(int i=0; i<n; i++)
   {
       ans[i].first=arr[i];
       ans[i].second=-1;
   }
   int val[q];
   int v=-mod;
   int id=-1;
   for(int i=0; i<q; i++) val[i]=-mod;
   for(int i=0; i<q; i++)
   {
       int x; cin >> x;
       if(x==1)
       {
           int j, m; cin >> j >> m;
           ans[j-1].first=m;
           ans[j-1].second=i;
       }
       else
       {
           int m; cin >>  m;
           val[i]=m;
           v=m;
           id=i;
       }
   }
   val[q-1]=v;
   int d=-mod;
   for(int i=id; i>=0; i--)
   {
       d=max(d,val[i]);
       val[i]=d;
   }
   for(int i=0; i<n; i++)
   {
       if(ans[i].second+1<=id) cout << max(ans[i].first, val[ans[i].second+1]) << " ";
       else cout << ans[i].first << " ";
   }
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long

int main()
{

   int n; cin >> n;
   int arr[n];
   for(int i=0; i<n; i++) cin >> arr[i];
   int q; cin >> q;
   vector< pair<int, int>>ans(n);
   for(int i=0; i<n; i++)
   {
       ans[i].first=arr[i];
       ans[i].second=-1;
   }
   int val[q];
   int v=-mod;
   for(int i=0; i<q; i++) val[i]=-mod;
   for(int i=0; i<q; i++)
   {
       int x; cin >> x;
       if(x==1)
       {
           int j, m; cin >> j >> m;
           ans[j-1].first=m;
           ans[j-1].second=i;
       }
       else
       {
           int m; cin >>  m;
           val[i]=m;
           v=m;
       }
   }
   val[q-1]=v;
   int d=-mod;
   for(int i=q-1; i>=0; i--)
   {
       d=max(d,val[i]);
       val[i]=d;
   }
   for(int i=0; i<n; i++)
   {
       if(ans[i].second+1<q) cout << max(ans[i].first, val[ans[i].second+1]) << " ";
       else cout << ans[i].first << " ";
   }
}


#include<bits/stdc++.h>
#include<algorithm>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define is insert
#define rep1(i,a,b) for(long long i=a;i<=b;i++)
#define mp make_pair
#define mh make_heap
#define F first
#define S second
//#define fin cin
//#define fout cout
#define file ifstream fin("input.txt");ofstream fout("output.txt");
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr(n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long int ll;
#define int long long
typedef pair<ll,ll> pairs;
typedef vector<ll> vi;
typedef vector<pairs> vpair;
int m=1e9+7;
//int L(int x){return u[x]==x?x:u[x]=L(u[x]);}
vpair  v;vi v1,v2;
//int L(int x){return u[x]==x?x:u[x]=L(u[x]);}
void solve()
{
    int a,b,c;std::vector<int>::iterator itr;
    cin>>a;
    if(a==1)
    {cin>>b>>c;itr = lower_bound(v2.begin(),v2.end(),b);int v;v=itr-v2.begin();//cout<<v<<endl;
        v1[v]=c;}

      else
      {
          cin>>b; itr =upper_bound(v1.begin(),v1.end(),b);int v=itr-v1.begin();//cout<<v<<endl;
          for(int i=0;i<v;i++)
          {
             if(v1[i]<b) v1[i]=b;

      }

}}

int32_t main()
{
    fast;
    int a,x;pairs z;
    cin>>a;
    fr(a){cin>>x;z=make_pair(x,i+1);v.pb(z);}
    sort(v.begin(),v.end());
     fr(a){
       v1.pb(v[i].F);v2.pb(v[i].S);
     }
    ll t=1;
 cin>>t;

   fr(t)
   solve();
 fr(a)
   cout<<v1[i]<<" ";

}


#include<bits/stdc++.h>
#include<algorithm>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define is insert
#define rep1(i,a,b) for(long long i=a;i<=b;i++)
#define mp make_pair
#define mh make_heap
#define F first
#define S second
//#define fin cin
//#define fout cout
#define file ifstream fin("input.txt");ofstream fout("output.txt");
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr(n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long int ll;
#define int long long
typedef pair<ll,ll> pairs;
typedef vector<ll> vi;
typedef vector<pairs> vpair;
//int L(int x){return u[x]==x?x:u[x]=L(u[x]);}
int32_t main()
{int w[200000]={},e[200000]={},q[200000],j,n,p[200000]={},mx[200000]={};vi  v;int a;
    fast;
int x;
    cin>>a;
    fr(a){cin>>x;v.pb(x);}

    ll t=1;
 cin>>t;

   fr(t)
  {

    cin>>q[i];if(q[i]==1){cin>>j>>n;w[j-1]=n;v[j-1]=n;e[j-1]=i;}
  else {
    cin>>p[i];
  }mx[t-1]=p[t-1];
  for(int i=t-2;i>=0;i--)
  {
      mx[i]=max(mx[i+1],p[i]);
  }
  }
for(int l=0;l<a;l++)
{
v[l]=max(v[l],mx[e[l]]);
    cout<<v[l]<<" ";}}


#include<bits/stdc++.h>
#include<algorithm>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define is insert
#define rep1(i,a,b) for(long long i=a;i<=b;i++)
#define mp make_pair
#define mh make_heap
#define F first
#define S second
//#define fin cin
//#define fout cout
#define file ifstream fin("input.txt");ofstream fout("output.txt");
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr(n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long int ll;
#define int long long
typedef pair<ll,ll> pairs;
typedef vector<ll> vi;
typedef vector<pairs> vpair;
//int L(int x){return u[x]==x?x:u[x]=L(u[x]);}
int32_t main()
{int w[200000]={},e[200000]={},q[200000],j,n,p[200000]={};vi  v;int a;
    fast;
int x;
    cin>>a;
    fr(a){cin>>x;v.pb(x);}

    ll t=1;
 cin>>t;

   fr(t)
  {

    cin>>q[i];if(q[i]==1){cin>>j>>n;w[j-1]=n;v[j-1]=n;e[j-1]=i;}
  else {
    cin>>p[i];
  }
  }
for(int l=0;l<a;l++)
{for(int i=e[l];i<t;i++)
v[l]=max(v[l],p[i]);
    cout<<v[l]<<" ";}}


#include<bits/stdc++.h>
#include<algorithm>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define is insert
#define rep1(i,a,b) for(long long i=a;i<=b;i++)
#define mp make_pair
#define mh make_heap
#define F first
#define S second
//#define fin cin
//#define fout cout
#define file ifstream fin("input.txt");ofstream fout("output.txt");
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr(n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long int ll;
#define int long long
typedef pair<ll,ll> pairs;
typedef vector<ll> vi;
typedef vector<pairs> vpair;
int m=1e9+7;
//int L(int x){return u[x]==x?x:u[x]=L(u[x]);}
vi  v;int a;
//int L(int x){return u[x]==x?x:u[x]=L(u[x]);}
void solve()
{
    int t,b,c;
    cin>>t;
    if(t==1)
    {

        cin>>b>>c;
        v[b-1]=c;
    }
    else{
        cin>>b;
        rep(i,0,a)
        {

            v[i]=max(v[i],b);
        }
    }
}

int32_t main()
{
    fast;
int x;
    cin>>a;
    fr(a){cin>>x;v.pb(x);}

    ll t=1;
 cin>>t;

   fr(t)
  {
    solve();
  }
 fr(a)
   cout<<v[i]<<" ";

}


#include<bits/stdc++.h>
#include<algorithm>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define is insert
#define rep1(i,a,b) for(long long i=a;i<=b;i++)
#define mp make_pair
#define mh make_heap
#define F first
#define S second
//#define fin cin
//#define fout cout
#define file ifstream fin("input.txt");ofstream fout("output.txt");
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr(n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long int ll;
#define int long long
typedef pair<ll,ll> pairs;
typedef vector<ll> vi;
typedef vector<pairs> vpair;
int m=1e9+7;
//int L(int x){return u[x]==x?x:u[x]=L(u[x]);}
vi  v;int a;
//int L(int x){return u[x]==x?x:u[x]=L(u[x]);}
void solve()
{

}

int32_t main()
{
    fast;
int x,p=0;
    cin>>a;
    fr(a){cin>>x;v.pb(x);}

    ll t=1;
 cin>>t;

   fr(t)
  {
    int q,w,e;
    cin>>q;
   if(q==1)
{
    cin>>w>>e;
    v[w-1]=e;
}
   else{
    cin>>w;p=max(p,w);

   }
  }
 fr(a)
   cout<<max(v[i],p)<<" ";

}


#include<bits/stdc++.h>
#include<algorithm>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define is insert
#define rep1(i,a,b) for(long long i=a;i<=b;i++)
#define mp make_pair
#define mh make_heap
#define F first
#define S second
//#define fin cin
//#define fout cout
#define file ifstream fin("input.txt");ofstream fout("output.txt");
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr(n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long int ll;
#define int long long
typedef pair<ll,ll> pairs;
typedef vector<ll> vi;
typedef vector<pairs> vpair;
//int L(int x){return u[x]==x?x:u[x]=L(u[x]);}
int32_t main()
{int w[200000]={},e[200000]={},q[200000],j,n,p[200000]={},mx[200000]={};vi  v;int a;
    fast;
int x;
    cin>>a;
    fr(a){cin>>x;v.pb(x);}

    ll t=1;
 cin>>t;

   fr(t)
  {

    cin>>q[i];if(q[i]==1){cin>>j>>n;w[j-1]=n;v[j-1]=n;e[j-1]=i;}
  else {
    cin>>p[i];
  }

  }mx[t-1]=p[t-1];for(int i=t-2;i>=0;i--)
  {
      mx[i]=max(mx[i+1],p[i]);
  }
for(int l=0;l<a;l++)
{
v[l]=max(v[l],mx[e[l]]);
    cout<<v[l]<<" ";}}


#include<bits/stdc++.h>
#define ll long long
#define loop(i,s,e) for(int i=s;i<e;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mk make_pair
using namespace std;
const int N=2e5+10;
int last[N],change[N],a[N];

int main(){
    fastio;
    int n; cin>>n;
    loop(i,1,n+1) cin>>a[i];
    int q; cin>>q;
    loop(i,1,q+1){
        int op; cin>>op;
        if(op==1){
            int p,x; cin>>p>>x;
            a[p]=x;
            last[p]=i;
        }
        else{
            int x; cin>>x;
            change[i]=x;
        }
    }
    for(int i=q-1;i>0;i--){
        change[i]=max(change[i+1],change[i]);
    }
    for(int i=1;i<=n;i++){
        a[i]=max(a[i],change[last[i]+1]);
        cout<<a[i]<<" ";
    }
}


#include<bits/stdc++.h>
#define ll long long
#define loop(i,s,e) for(int i=s;i<e;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mk make_pair
using namespace std;
const int N=2e5+10;
int last[N],change[N],a[N];

int main(){
    fastio;
    int n; cin>>n;
    loop(i,1,n+1) cin>>a[i];
    int q; cin>>q;
    loop(i,1,q+1){
        int op; cin>>op;
        if(op==1){
            int p,x; cin>>p>>x;
            a[p]=x;
            last[p]=x;
        }
        else{
            int x; cin>>x;
            change[i]=x;
        }
    }
    for(int i=q-1;i>0;i--){
        change[i]=max(change[i+1],change[i]);
    }
    for(int i=1;i<=n;i++){
        a[i]=max(a[i],change[last[i]+1]);
        cout<<a[i]<<" ";
    }
}


#include<bits/stdc++.h>
#define ll long long
#define loop(i,s,e) for(int i=s;i<e;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mk make_pair
using namespace std;
const int N=2e5+10;
int last[N],change[N],a[N];

int main(){
    fastio;
    int n; cin>>n;
    loop(i,1,n+1) cin>>a[i];
    int q; cin>>q;
    loop(i,1,q+1){
        int op; cin>>op;
        if(op==1){
            int p,x; cin>>p>>x;
            a[p]=x;
            last[p]=x;
        }
        else{
            int x; cin>>x;
            change[i]=x;
        }
    }
    for(int i=q-1;i>0;i--){
        change[i]=max(change[i+1],change[i]);
    }
    for(int i=1;i<=n;i++){
        cout<<max(a[i],change[last[i]+1])<<" ";
    }
}


#include<bits/stdc++.h>
#define ll long long
#define loop(i,s,e) for(int i=s;i<e;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mk make_pair
using namespace std;
const int N=2e5+10;
int last[N],change[N],a[N];

int main(){
    fastio;
    int n; cin>>n;
    loop(i,1,n+1) cin>>a[i];
    int q; cin>>q;
    loop(i,1,q+1){
        int op; cin>>op;
        if(op==1){
            int p,x; cin>>p>>x;
            a[p]=x;
            last[p]=x;
        }
        else{
            int x; cin>>x;
            change[i]=x;
        }
    }
    for(int i=n;i>0;i--){
        change[i]=max(change[i+1],change[i]);
    }
    for(int i=1;i<=n;i++){
        cout<<max(a[i],change[last[i]+1])<<" ";
    }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n,q,temp,max=0,ptr=0;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++){
        cin>>ar[i];
    }
    cin>>q;
    int br[q][2],arr[q][2],a=0,b=0;
    stack<int> stk,stk_ptr;
    for(int i=0;i<q;i++){
        cin>>temp;
        if(temp==2){
        cin>>arr[a][0];
        arr[a][1]=b;
        a++;}
        else if(temp==1){
            cin>>br[b][0]>>br[b][1];
            br[b][0] = br[b][0]-1;
            b++;
        }
    }

    max=b;
    stk.push(arr[a-1][0]);
    stk_ptr.push(arr[a-1][1]);
    for(int i=a-2;i>=0;i--){
        if(arr[i][0]>=stk.top()){
            stk.push(arr[i][0]);
            stk_ptr.push(arr[i][1]);
        }
    }
    b=0;

    while(stk.empty()==false){
         temp=stk.top();
         ptr=stk_ptr.top();
        // cout<<temp;
         for(;b<ptr;b++){
             ar[br[b][0]]=br[b][1];
         }
        for(int i=0;i<n;i++){
            if(ar[i]<temp){
                ar[i]=temp;
            }
        }
        stk.pop();
        stk_ptr.pop();
    }
    for (; b < max; b++)
    {
        ar[br[b][0]] = br[b][1];
    }
    for (int i = 0; i < n; i++)
    {
        cout<<ar[i]<<" ";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n,q,temp,max=0,ptr=0;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++){
        cin>>ar[i];
    }
    cin>>q;
    int br[q][2],arr[q][2],a=0,b=0;
    stack<int> stk,stk_ptr;
    for(int i=0;i<q;i++){
        cin>>temp;
        if(temp==2){
        cin>>arr[a][0];
        arr[a][1]=b;
        a++;}
        else if(temp==1){
            cin>>br[b][0]>>br[b][1];
            br[b][0] = br[b][0]-1;
            b++;
        }
    }
   int flag=0;
    max=b;
    if(a==0){
        flag=1;
    }
    else
    {
        stk.push(arr[a - 1][0]);
        stk_ptr.push(arr[a - 1][1]);
        for (int i = a - 2; i >= 0; i--)
        {
            if (arr[i][0] > stk.top())
            {
                stk.push(arr[i][0]);
                stk_ptr.push(arr[i][1]);
            }
        }
    }

    b=0;

    while(stk.empty()==false){
         temp=stk.top();
         ptr=stk_ptr.top();
        // cout<<temp;
         for(;b<ptr;b++){
             ar[br[b][0]]=br[b][1];
         }
        for(int i=0;i<n;i++){
            if(ar[i]<temp){
                ar[i]=temp;
            }
        }
        stk.pop();
        stk_ptr.pop();
    }
    for (; b < max; b++)
    {
        ar[br[b][0]] = br[b][1];
    }
    for (int i = 0; i < n; i++)
    {
        cout<<ar[i]<<" ";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n,q,temp,max=0,ptr=0;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++){
        cin>>ar[i];
    }
    cin>>q;
    int br[q][2],arr[q],a=0,b=0;
    for(int i=0;i<q;i++){
        cin>>temp;
        if(temp==2){
        cin>>arr[a];
        if(arr[a]>max){
            max = arr[a];
            ptr=b;
        }
        a++;}
        else if(temp==1){
            cin>>br[b][0]>>br[b][1];
            br[b][0] = br[b][0]-1;
            b++;
        }
    }
    for(int i=0;i<ptr;i++){
        ar[br[i][0]]=br[i][1];
    }
    for (int i = 0; i < n; i++)
    {
        if(ar[i]<max){
            ar[i]=max;
        }
    }
    for (int i = ptr; i < b; i++)
    {
        ar[br[i][0]] = br[i][1];
    }
    for (int i = 0; i < n; i++)
    {
        cout<<ar[i]<<" ";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n,q,temp,max=0,ptr=0;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++){
        cin>>ar[i];
    }
    cin>>q;
    int br[q][2],arr[q][2],a=0,b=0;
    stack<int> stk,stk_ptr;
    for(int i=0;i<q;i++){
        cin>>temp;
        if(temp==2){
        cin>>arr[a][0];
        arr[a][1]=b;
        a++;}
        else if(temp==1){
            cin>>br[b][0]>>br[b][1];
            br[b][0] = br[b][0]-1;
            b++;
        }
    }
   int flag=0;
    max=b;
    if(a==0){
        flag=1;
    }
    else
    {
        stk.push(arr[a - 1][0]);
        stk_ptr.push(arr[a - 1][1]);
        for (int i = a - 2; i >= 0; i--)
        {
            if (arr[i][0] >= stk.top())
            {
                stk.push(arr[i][0]);
                stk_ptr.push(arr[i][1]);
            }
        }
    }

    b=0;

    while(stk.empty()==false){
         temp=stk.top();
         ptr=stk_ptr.top();
        // cout<<temp;
         for(;b<ptr;b++){
             ar[br[b][0]]=br[b][1];
         }
        for(int i=0;i<n;i++){
            if(ar[i]<temp){
                ar[i]=temp;
            }
        }
        stk.pop();
        stk_ptr.pop();
    }
    for (; b < max; b++)
    {
        ar[br[b][0]] = br[b][1];
    }
    for (int i = 0; i < n; i++)
    {
        cout<<ar[i]<<" ";
    }
    return 0;
}


/* author   : mpily :-()
title : Competing.cpp
time :Sat Jan 18 17:39:16 2020

*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<pair<int,int>>arr(n);
	for(int i = 0; i < n; i++){
		cin>>arr[i].first;
		arr[i].second = 0;
	}
	int lpos = 0;
	int qnum = 1;
	vector<pair<int,int>>payoffs;
	int q;
	cin>>q;
	for(int i = 0; i < q; i++){
		int type;
		cin>>type;
		if(type == 1){
			int p,x;
			cin>>p>>x;
			p--;
			arr[p].first = x;
			arr[p].second = qnum;
		}
		else if(type == 2){
			int x;
			cin>>x;
			//do binary search  on the payoffs and find the first element smaller than x
			int mn = 0;
			int mx = lpos;
			int md = mn +(mx-mn)/2;
			while(mn < mx){
				//cout<<md<<" stuck in a loop ? \n";
				if(payoffs[md].first <= x){
					mx = md;
					md = mn + (mx-mn)/2;
				}
				else if(payoffs[md].first > x){
					mn = md+1;
					md = mn + (mx-mn)/2;
				}
			}
			if(md >= payoffs.size()){
				payoffs.push_back(make_pair(x,qnum));
				lpos = md+1;
			}
			else{
				payoffs[md].first = x;
				payoffs[md].second = qnum;
				lpos = md+1;
			}
		}
		qnum+=1;
	}
	for(int i = 0; i < n; i++){
		int mn = 0;
		int mx = lpos;
		int md = mn + (mx-mn)/2;
		while(mn < mx){
			//cout<<md<<" stuck in a loop 2 ? \n we have that "<<arr[i].first<<" was put at "<<arr[i].second<<" and its best option is"<<payoffs[md].first<<" which was put at "<<payoffs[md].second<<"\n";
			if(payoffs[md].second > arr[i].second){
				//cout<<"for "<<arr[i].first<<" we have gotten here \n";
				mx = md;
				md = mn + (mx-mn)/2;
			}
			else if(payoffs[md].second < arr[i].second){
				mn  = md+1;
				md = mn + (mx-mn)/2;
			}
		}
		if(md < payoffs.size() && payoffs[md].first > arr[i].first)
		arr[i].first = payoffs[md].first;
	}
	for(auto a : arr){
		cout<<a.first<<" ";
	}
	cout<<"\n";
	return 0;
}


/* author   : mpily :-()
title : Competing.cpp
time :Sat Jan 18 17:39:16 2020

*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<pair<int,int>>arr(n);
	for(int i = 0; i < n; i++){
		cin>>arr[i].first;
		arr[i].second = 0;
	}
	int lpos = 0;
	int qnum = 1;
	vector<pair<int,int>>payoffs;
	int q;
	cin>>q;
	for(int i = 0; i < q; i++){
		int type;
		cin>>type;
		if(type == 1){
			int p,x;
			cin>>p>>x;
			p--;
			arr[p].first = x;
			arr[p].second = qnum;
		}
		else if(type == 2){
			int x;
			cin>>x;
			//do binary search  on the payoffs and find the first element smaller than x
			int mn = 0;
			int mx = lpos;
			int md = mn +(mx-mn)/2;
			while(mn < mx){
				//cout<<md<<" stuck in a loop ? \n";
				if(payoffs[md].first <= x){
					mx = md;
					md = mn + (mx-mn)/2;
				}
				else if(payoffs[md].first > x){
					mn = md+1;
					md = mn + (mx-mn)/2;
				}
			}
			if(md >= payoffs.size()){
				payoffs.push_back(make_pair(x,qnum));
				lpos = md+1;
			}
			else{
				payoffs[md].first = x;
				payoffs[md].second = qnum;
				lpos = md+1;
			}
		}
		qnum+=1;
	}
	for(int i = 0; i < n; i++){
		int mn = 0;
		int mx = lpos;
		int md = mn + (mx-mn)/2;
		while(mn < mx){
			//cout<<md<<" stuck in a loop 2 ? \n we have that "<<arr[i].first<<" was put at "<<arr[i].second<<" and its best option is"<<payoffs[md].first<<" which was put at "<<payoffs[md].second<<"\n";
			if(payoffs[md].second > arr[i].second){
				//cout<<"for "<<arr[i].first<<" we have gotten here \n";
				mx = md;
				md = mn + (mx-mn)/2;
			}
			else if(payoffs[md].second < arr[i].second){
				mn  = md+1;
				md = mn + (mx-mn)/2;
			}
		}
		if(md < lpos && payoffs[md].first > arr[i].first)
		arr[i].first = payoffs[md].first;
	}
	for(auto a : arr){
		cout<<a.first<<" ";
	}
	cout<<"\n";
	return 0;
}


/* author   : mpily :-()
title : Competing.cpp
time :Sat Jan 18 17:39:16 2020

*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<pair<int,int>>arr(n);
	for(int i = 0; i < n; i++){
		cin>>arr[i].first;
		arr[i].second = 0;
	}
	int lpos = 0;
	int qnum = 1;
	vector<pair<int,int>>payoffs;
	int q;
	cin>>q;
	for(int i = 0; i < q; i++){
		int type;
		cin>>type;
		if(type == 1){
			int p,x;
			cin>>p>>x;
			p--;
			arr[p].first = x;
			arr[p].second = qnum;
		}
		else if(type == 2){
			int x;
			cin>>x;
			//do binary search  on the payoffs and find the first element smaller than x
			int mn = 0;
			int mx = lpos;
			int md = mn +(mx-mn)/2;
			while(mn < mx){
				//cout<<md<<" stuck in a loop ? \n";
				if(payoffs[md].first <= x){
					mx = md;
					md = mn + (mx-mn)/2;
				}
				else if(payoffs[md].first > x){
					mn = md+1;
					md = mn + (mx-mn)/2;
				}
			}
			if(md >= payoffs.size()){
				payoffs.push_back(make_pair(x,qnum));
				lpos = md+1;
			}
			else{
				payoffs[md].first = x;
				payoffs[md].second = qnum;
				lpos = md+1;
			}
		}
		qnum+=1;
	}
	for(int i = 0; i < n; i++){
		int mn = 0;
		int mx = lpos;
		int md = mn + (mx-mn)/2;
		while(mn < mx){
			//cout<<md<<" stuck in a loop 2 ? \n we have that "<<arr[i].first<<" was put at "<<arr[i].second<<" and its best option is 				"<<payoffs[md].first<<" which was put at "<<payoffs[md].second<<"\n";
			if(payoffs[md].second > arr[i].second && payoffs[md].first >= payoffs[md].first){
				//cout<<"for "<<arr[i].first<<" we have gotten here \n";
				mx = md;
				md = mn + (mx-mn)/2;
			}
			else if(payoffs[md].second < arr[i].second){
				mn  = md+1;
				md = mn + (mx-mn)/2;
			}
		}
		if(md < payoffs.size() && payoffs[md].first > arr[i].first)
		arr[i].first = payoffs[md].first;
	}
	for(auto a : arr){
		cout<<a.first<<" ";
	}
	cout<<"\n";
	return 0;
}


/* author   : mpily :-()
title : Competing.cpp
time :Sat Jan 18 17:39:16 2020

*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<pair<int,int>>arr(n);
	for(int i = 0; i < n; i++){
		cin>>arr[i].first;
		arr[i].second = 0;
	}
	int lpos = 0;
	int qnum = 1;
	vector<pair<int,int>>payoffs;
	int q;
	cin>>q;
	for(int i = 0; i < q; i++){
		int type;
		cin>>type;
		if(type == 1){
			int p,x;
			cin>>p>>x;
			p--;
			arr[p].first = x;
			arr[p].second = qnum;
		}
		else if(type == 2){
			int x;
			cin>>x;
			//do binary search  on the payoffs and find the first element smaller than x
			int mn = 0;
			int mx = lpos;
			int md = mn +(mx-mn)/2;
			while(mn < mx){
				//cout<<md<<" stuck in a loop ? \n";
				if(payoffs[md].first <= x){
					mx = md;
					md = mn + (mx-mn)/2;
				}
				else if(payoffs[md].first > x){
					mn = md+1;
					md = mn + (mx-mn)/2;
				}
			}
			if(md >= payoffs.size()){
				payoffs.push_back(make_pair(x,qnum));
				lpos = md+1;
			}
			else{
				payoffs[md].first = x;
				payoffs[md].second = qnum;
				lpos = md+1;
			}
		}
		qnum+=1;
	}
	for(int i = 0; i < n; i++){
		int mn = 0;
		int mx = lpos;
		int md = mn + (mx-mn)/2;
		while(mn < mx){
			//cout<<md<<" stuck in a loop 2 ? \n we have that "<<arr[i].first<<" was put at "<<arr[i].second<<" and its best option is 				"<<payoffs[md].first<<" which was put at "<<payoffs[md].second<<"\n";
			if(payoffs[md].second > arr[i].second && payoffs[md].first >= arr[i].first){
				//cout<<"for "<<arr[i].first<<" we have gotten here \n";
				mx = md;
				md = mn + (mx-mn)/2;
			}
			else if(payoffs[md].second < arr[i].second){
				mn  = md+1;
				md = mn + (mx-mn)/2;
			}
		}
		if(md < lpos && payoffs[md].first > arr[i].first)
		arr[i].first = payoffs[md].first;
	}
	for(auto a : arr){
		cout<<a.first<<" ";
	}
	cout<<"\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
//3
#define lli long long int
#define size 200005
lli pp[size];
lli xx[size];
int main()
{
    int n;
    cin>>n;
    lli array[n];
    for(int i=0;i<n;i++)cin>>array[i];

    int q;
    cin>>q;
    for(int i=0;i<q;i++)
    {
        int one;
        cin>>one;
        if(one==1)
        {
            lli p,px;
            cin>>p>>px;
            pp[p-1]=i;
            array[p-1]=px;
        }
        else if(one==2)
        {
            lli x;
            cin>>x;
            xx[i]=x;
        }
    }
    for(int i=q-1; i>=0; i--)
        xx[i]=max(xx[i],xx[i+1]);

    for(int i=0;i<n;i++)
        array[i]=max(array[i],xx[pp[i]]);

    cout<<array[0];
    for(int i=1;i<n;i++)
        cout<<" "<<array[i];
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
//3
#define lli long long int
int mark[2*100000+5];
int main()
{
    int n,tp;
    cin>>n;
    lli array[n+1],i;
    int mark[n+1];
    for(i=1;i<=n;i++)cin>>array[i];
    int q,max=0,max1=0;
    cin>>q;
    tp=0;
    for(i=0;i<q;i++)
    {
        int p,px,x=0,one;

        cin>>one;
        if(one==2)
        {
            cin>>x;
            if(max<x)max=x;
            max1=max;
        }
        else if(one==1)
        {
            tp=1;
            if(max1!=0)
            {
                for(int j=1;j<=n;j++)
                    if(array[j]<max1)array[j]=max1;
                max1=0;
            }
            cin>>p>>px;
            array[p]=px;
        }

    }
    if(tp==0)
        {cout<<"for test"<<endl;for(int j=1;j<=n;j++)
            if(array[j]<max1)array[j]=max1;}
    for(i=1;i<n;i++)
    {
        cout<<array[i]<<" ";
    }
    cout<<array[n]<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
//3
#define lli long long int
int mark[2*100000+5];
int main()
{
    int n;
    cin>>n;
    lli array[n+1],i;
    int mark[n+1];
    for(i=1;i<=n;i++)cin>>array[i];
    int q,max=0;
    cin>>q;
    for(i=0;i<q;i++)
    {
        int p,px,x=0,one;

        cin>>one;
        if(one==2)
        {
            cin>>x;
            if(max<x)max=x;
        }
        else if(one==1)
        {
            if(max!=0)
            {
                for(int j=1;j<=n;j++)
                    if(array[j]<max)array[j]=max;
                max=0;
            }
            cin>>p>>px;
            array[p]=px;
        }
    }
    for(i=1;i<n;i++)
    {
        cout<<array[i]<<" ";
    }
    cout<<array[n]<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
//3
#define lli long long int
int mark[2*100000+5];
int main()
{
    int n;
    cin>>n;
    lli array[n+1],i;
    int mark[n+1];
    for(i=1;i<=n;i++)cin>>array[i];
    int q,max=0,max1=0;
    cin>>q;
    int tp=0,xp=0,xpmax=0;
    for(i=0;i<q;i++)
    {
        int p,px,x=0,one;

        cin>>one;
        if(one==2)
        {
            cin>>x;
            if(max<x)max=x;
            max1=max;
            xp=0;
            if(xpmax<x)xpmax=x;
        }
        else if(one==1)
        {
            tp=1;xp=1;xpmax=0;
            if(max1!=0)
            {
                for(int j=1;j<=n;j++)
                    if(array[j]<max1)array[j]=max1;
                max1=0;
            }
            cin>>p>>px;
            array[p]=px;
        }

    }
    if(tp==0)
        {for(int j=1;j<=n;j++)
            if(array[j]<max1)array[j]=max1;}
    else if(xp==0)
    {
        for(int j=1;j<=n;j++)
            if(array[j]<xpmax)array[j]=xpmax;
    }
    for(i=1;i<n;i++)
    {
        cout<<array[i]<<" ";
    }
    cout<<array[n]<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
//3
#define lli long long int
int mark[2*100000+5];
int main()
{
    int n,tp;
    cin>>n;
    lli array[n+1],i;
    int mark[n+1];
    for(i=1;i<=n;i++)cin>>array[i];
    int q,max=0,max1=0;
    cin>>q;
    tp=0;
    for(i=0;i<q;i++)
    {
        int p,px,x=0,one;

        cin>>one;
        if(one==2)
        {
            cin>>x;
            if(max<x)max=x;
            max1=max;
            tp=0;
        }
        else if(one==1)
        {
            tp=1;
            if(max1!=0)
            {
                for(int j=1;j<=n;j++)
                    if(array[j]<max1)array[j]=max1;
                max1=0;
            }
            cin>>p>>px;
            array[p]=px;
        }

    }
    if(tp==0)
        {for(int j=1;j<=n;j++)
            if(array[j]<max1)array[j]=max1;}
    for(i=1;i<n;i++)
    {
        cout<<array[i]<<" ";
    }
    cout<<array[n]<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
//3
#define lli long long int
int mark[2*100000+5];
int main()
{
    int n;
    cin>>n;
    lli array[n+1],i;
    int mark[n+1];
    for(i=1;i<=n;i++)cin>>array[i];
    int q,max=0,max1=0;
    cin>>q;
    int tp=0,xp=0,xpmax=0;
    for(i=0;i<q;i++)
    {
        int p,px,x=0,one;

        cin>>one;
        if(one==2)
        {
            cin>>x;
            if(max<x)max=x;
            max1=max;
            xp=0;
            if(xpmax<x)xpmax=x;
        }
        else if(one==1)
        {
            tp=1;xp=1;xpmax=0;
            if(max1!=0)
            {
                for(int j=1;j<=n;j++)
                    if(array[j]<max1)array[j]=max1;
                max1=0;
            }
            cin>>p>>px;
            array[p]=px;
        }

    }
    if(tp==0)
        {for(int j=1;j<=n;j++)
            if(array[j]<max1)array[j]=max1;}
    if(xp==0)
    {
        for(int j=1;j<=n;j++)
            if(array[j]<xpmax)array[j]=xpmax;
    }
    for(i=1;i<n;i++)
    {
        cout<<array[i]<<" ";
    }
    cout<<array[n]<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
//3
#define lli long long int
int mark[2*100000+5];
int main()
{
    int n;
    cin>>n;
    lli array[n+1],i;
    int mark[n+1];
    for(i=1;i<=n;i++)cin>>array[i];
    int q,max=0,max1=0;
    cin>>q;
    for(i=0;i<q;i++)
    {
        int p,px,x=0,one,tp=0;

        cin>>one;
        if(one==2)
        {
            cin>>x;
            if(max<x)max=x;
            max1=max;
        }
        else if(one==1)
        {
            if(max1!=0)
            {
                for(int j=1;j<=n;j++)
                    if(array[j]<max1)array[j]=max1;
                max1=0;
            }
            cin>>p>>px;
            array[p]=px;
            tp=1;
        }
        if(tp==0)
        for(int j=1;j<=n;j++)
            if(array[j]<max1)array[j]=max1;
    }
    for(i=1;i<n;i++)
    {
        cout<<array[i]<<" ";
    }
    cout<<array[n]<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
//3
#define lli long long int
int mark[2*100000+5];
int main()
{
    int n;
    cin>>n;
    lli array[n+1],i;
    int mark[n+1];
    for(i=1;i<=n;i++)cin>>array[i];
    int q,max=0,max1=0;
    cin>>q;
    for(i=0;i<q;i++)
    {
        int p,px,x=0,one;

        cin>>one;
        if(one==2)
        {
            cin>>x;
            if(max<x){max=x;max1=max;}
        }
        else if(one==1)
        {
            if(max1!=0)
            {
                for(int j=1;j<=n;j++)
                    if(array[j]<max1)array[j]=max1;
                max1=0;
            }
            cin>>p>>px;
            array[p]=px;
        }
    }
    for(i=1;i<n;i++)
    {
        cout<<array[i]<<" ";
    }
    cout<<array[n]<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
//3
#define lli long long int
int mark[2*100000+5];
int main()
{
    int n,tp;
    cin>>n;
    lli array[n+1],i;
    int mark[n+1];
    for(i=1;i<=n;i++)cin>>array[i];
    int q,max=0,max1=0;
    cin>>q;
    tp=0;
    for(i=0;i<q;i++)
    {
        int p,px,x=0,one;

        cin>>one;
        if(one==2)
        {
            cin>>x;
            if(max<x)max=x;
            max1=max;
        }
        else if(one==1)
        {
            tp=1;
            if(max1!=0)
            {
                for(int j=1;j<=n;j++)
                    if(array[j]<max1)array[j]=max1;
                max1=0;
            }
            cin>>p>>px;
            array[p]=px;
        }

    }
    if(tp==0)
        {for(int j=1;j<=n;j++)
            if(array[j]<max1)array[j]=max1;}
    for(i=1;i<n;i++)
    {
        cout<<array[i]<<" ";
    }
    cout<<array[n]<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
//3
#define lli long long int
int mark[2*100000+5];
int main()
{
    int n;
    cin>>n;
    lli array[n+1],i;
    int mark[n+1];
    for(i=1;i<=n;i++)cin>>array[i];
    int q,max=0,max1=0;
    cin>>q;
    for(i=0;i<q;i++)
    {
        int p,px,x=0,one;

        cin>>one;
        if(one==2)
        {
            cin>>x;
            if(max<x)max=x;
            max1=max;
        }
        else if(one==1)
        {
            if(max1!=0)
            {
                for(int j=1;j<=n;j++)
                    if(array[j]<max1)array[j]=max1;
                max1=0;
            }
            cin>>p>>px;
            array[p]=px;
        }
    }
    for(i=1;i<n;i++)
    {
        cout<<array[i]<<" ";
    }
    cout<<array[n]<<endl;
    return 0;
}


#include<bits/stdc++.h>
#include<stdio.h>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<vector>
#include<utility>
#include<cstring>
#include<limits.h>
#define pb(a)             push_back(a)
#define mp(a,b)           make_pair(a,b)
#define pf printf
#define ff first
#define ss second
#define sef second.first
#define ses second.second
#define PI 3.14159265 /// tan inverse = atan(value)*(180/PI)
#define ms(a,b)            memset(a, b, sizeof(a))
#define lp(i,a,b) for (int i = a; i <= b; i++)
#define pii                pair <int,int>
#define sl(a)              scanf("%I64d",&a)
#define sll(a,b)           scanf("%I64d %I64d",&a,&b)
#define si(a)              scanf("%d",&a)
#define sii(a,b)           scanf("%d %d",&a,&b)
#define EulerGamma 0.57721566490153286060651209;/// when n>1e6  nth harmonic num = log(x+.5)+EulerGamma;
///UINT_MAX 2^32
///ULLONG_MAX 2^64
/* int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; */ // 4 Direction
/* int dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; */ // 8 Direction
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction
/*-----------------------Bitmask------------------*/
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/
#define all(v) (v).begin(),(v).end()
#define S(x) scanf("%d",&(x))
#define S2(x,y) scanf("%d%d",&(x),&(y))
#define SL(x) scanf("%lld",&(x))
#define SL2(x) scanf("%lld%lld",&(x),&(y))
#define P(x) printf("%d\n",(x))
using namespace std ;
typedef long long ll ;
const int maxx = 2e5+10;
stack < pii > lvl ;
map < int ,int > last ;
ll dp[maxx+5],arr[maxx+5],id[maxx+5],row[maxx+5],rep[maxx+5];
map < int , bool > used ;
int main()
{
    ll n ;
    cin >> n ;
    for(int i=1;i<=n;i++)
    {
        ll x ;
        cin >> x ;
        arr[i]=x;
    }
    ll q ;
    cin >> q ;
    for(int i=1;i<=q;i++)
    {
        ll sym,p=0,idx,v;
        cin >> sym ;
        if(sym==1)
        {
            cin >> idx >> v ;
            row[idx]=i;
            rep[idx]=v;
            used[idx]=true;
        }
        else
        {
            cin >> p ;
        }
        id[i]=p;
    }
    ll best=0;
    for(int i=q;i>0;i--)
    {
        best = max(best,id[i]);
        id[i]=best;
    }
    for(auto x : used)
    {
       arr[x.ff]=max(id[row[x.ff]],rep[x.ff]);
    }
    for(int i=1;i<=n;i++)
    {
        if(i!=1){cout << " " ;}
        if(used[i])
        {
            cout << arr[i];
        }
        else
        {
            arr[i]=max(arr[i],best);
            cout << arr[i] ;
        }
    }
    cout << endl;
    return 0 ;
}