<image>

Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting.

The game consists of multiple rounds. Its rules are very simple: in each round, a natural number k is chosen. Then, the one who says (or barks) it faster than the other wins the round. After that, the winner's score is multiplied by k2, and the loser's score is multiplied by k. In the beginning of the game, both Slastyona and Pushok have scores equal to one.

Unfortunately, Slastyona had lost her notepad where the history of all n games was recorded. She managed to recall the final results for each games, though, but all of her memories of them are vague. Help Slastyona verify their correctness, or, to put it another way, for each given pair of scores determine whether it was possible for a game to finish with such result or not.

Input

In the first string, the number of games n (1 ≤ n ≤ 350000) is given.

Each game is represented by a pair of scores a, b (1 ≤ a, b ≤ 109) – the results of Slastyona and Pushok, correspondingly.

Output

For each pair of scores, answer "Yes" if it's possible for a game to finish with given score, and "No" otherwise.

You can output each letter in arbitrary case (upper or lower).

Example

Input

6
2 4
75 45
8 8
16 16
247 994
1000000000 1000000


Output

Yes
Yes
Yes
No
No
Yes

Note

First game might have been consisted of one round, in which the number 2 would have been chosen and Pushok would have won.

The second game needs exactly two rounds to finish with such result: in the first one, Slastyona would have said the number 5, and in the second one, Pushok would have barked the number 3.
  //  package com.company;
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.lang.reflect.Array;
    import java.util.*;
    public class Main {

        public static void main(String[] args) throws IOException {
         //   Scanner s = new Scanner(System.in);
            BufferedReader s=new BufferedReader(new InputStreamReader(System.in));
             StringBuilder sb = new StringBuilder();
    int n=Integer.parseInt(s.readLine());
    for(int i=0;i<n;i++){
        String[] str=s.readLine().trim().split("\\s+");
        double a=Double.parseDouble(str[0]);double b=Double.parseDouble(str[1]);double x=Math.cbrt(a*b);
        if(x==Math.floor(x)&&a%x==0&&b%x==0){
            sb.append("YES\n");
        }else
            sb.append("NO\n");
    }
            System.out.println(sb.toString());
        }
         static double power(double x, long y, int p) {
            double res = 1;
            x = x % p;
            while (y > 0) {
                if ((y & 1) == 1)
                    res = (res * x) % p;
                y = y >> 1;
                x = (x * x) % p;
            }
            return res;
        }
        public static void fracion(double x) {
            String a = "" + x;
            String spilts[] = a.split("\\."); // split using decimal
            int b = spilts[1].length(); // find the decimal length
            int denominator = (int) Math.pow(10, b); // calculate the denominator
            int numerator = (int) (x * denominator); // calculate the nerumrator Ex
            // 1.2*10 = 12
            int gcd = gcd(numerator, denominator); // Find the greatest common
            // divisor bw them
            String fraction = "" + numerator / gcd + "/" + denominator / gcd;
            // System.out.println((denominator/gcd));
            long x1=modInverse(denominator / gcd,998244353  );
            //  System.out.println(x1);
            System.out.println((((numerator / gcd )%998244353 *(x1%998244353  ))%998244353  ) );
        }static int max=Integer.MIN_VALUE;
static int max1=Integer.MIN_VALUE;static int[] ans;static long[][] dp;static int[][] c;
        public static int dfs(int papa, int i, ArrayList<Integer>[] h, int[] vis) {

             vis[i] = 1;
               if(papa!=-1){
                   dp[i-1][0]=Math.min(dp[i-1][0],c[0][i-1]+Math.min(dp[papa-1][1],dp[papa-1][2]));
                   dp[i-1][1]=Math.min(dp[i-1][1],c[1][i-1]+Math.min(dp[papa-1][0],dp[papa-1][2]));
                   dp[i-1][2]=Math.min(dp[i-1][2],c[2][i-1]+Math.min(dp[papa-1][1],dp[papa-1][0]));

               }else{
                   dp[i-1][0]=c[i-1][0];
                   dp[i-1][1]=c[i-1][1];
                   dp[i-1][2]=c[i-1][2];

               }
             for(Integer j:h[i]){
                      if(vis[j]==0){
                          dfs(i,j,h,vis);
                      }
             }ans[i]+=1;if(ans[i]>max){
                 max=ans[i];max1=i;
            }
          return ans[i];
        }



        public static void bfs(int i, HashMap<Integer, Integer>[] h, int[] vis, int len, int papa) {
            Queue<Integer> q = new LinkedList<Integer>();
            q.add(i);

        }


        static int i(String a) {
            return Integer.parseInt(a);
        }

        static long l(String a) {
            return Long.parseLong(a);
        }

        static String[] inp() throws IOException {
            BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
            return s.readLine().trim().split("\\s+");
        }


        static int gcd(int a, int b) {
            if (b == 0)
                return a;
            return gcd(b, a % b);
        }
        static long modInverse(int a, int m)
        {


            {
                // If a and m are relatively prime, then modulo inverse
                // is a^(m-2) mode m
                return (power(a, m - 2, m));
            }
        }

        // To compute x^y under modulo m
        static long power(int x, int y, int m)
        {
            if (y == 0)
                return 1;

            long p = power(x, y / 2, m) % m;
            p = (p * p) % m;

            if (y % 2 == 0)
                return p;
            else
                return (x * p) % m;
        }

        // Function to return gcd of a and b

    }
    class Student
    {
        int l,r;

        public Student(int l, int r) {
            this.l = l;
            this.r = r;

        }
    // Constructor


        // Used to print student details in main()
        public String toString()
        {
            return this.l+" ";
        }
    }

    class Sortbyroll implements Comparator<Student>
    {
        // Used for sorting in ascending order of
        // roll number
        public int compare(Student a, Student b){
            return a.l-b.l;
        }
    }