<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.
                                                                      //>>>BaZ<<<//
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class RR {
    static int dx[] = {-1,1,0,0,};
    static int dy[] = {0,0,1,-1};
    static long MOD = 1000000007;
    static int INF = Integer.MAX_VALUE/10;
    static MyScanner scan;
    static PrintWriter out;
    static StringBuilder sb;
    //static MyFileReader scan;
    //static PrintWriter out;
    public static void main(String[] args) {
        new Thread(null,null,"BaZ",99999999)
        {
           public void run() 
           {
               try
               {
                   solve();
               }
               catch(Exception e)
               {   
                   e.printStackTrace();
                   System.exit(1);
               }
           }
        }.start();
    }
    static void solve() throws IOException
    { 
       Calendar CAL1 = Calendar.getInstance();
       CAL1.setTime(new Date());
       out = new PrintWriter(System.out,true);  
       scan = new MyScanner();
       sb = new StringBuilder();
       //scan = new MyFileReader();   //File input
       //out = new PrintWriter(new File("C://Users/Aman deep/Desktop/output.txt"));  //File output
       int t = ni();
       while(t-->0)
       {
            long a = nl();
            long b = nl();
            long p = a*b;
            long cb = (long)cbrt(p);
            if(cb*cb*cb==p && a%cb==0 && b%cb==0)
                sb.append("Yes\n");
            else sb.append("No\n");
       }
       out.print(sb);
       Calendar CAL2 = Calendar.getInstance();
       CAL2.setTime(new Date());
       double Execution_Time = (double)(CAL2.getTimeInMillis()-CAL1.getTimeInMillis())/1000.000;
       //System.out.println("Execution time : "+Execution_Time+" seconds");
       out.flush();   
       out.close();
    }
    static int ni() throws IOException
    {
        return scan.nextInt();
    }
    static long nl() throws IOException
    {
        return scan.nextLong();
    }
    static double nd() throws IOException
    {
        return scan.nextDouble();
    }
    static String next() throws IOException
    {
        return scan.next();
    }
    static void print(Object o)
    {
        out.print(o+" ");
    }
    static void println(Object o)
    {
        out.println(o);
    }
    static void println()
    {
        out.println();
    }
    static void add(TreeMap<Integer,Integer> tm,int val)
    {
        if(tm.containsKey(val))
            tm.put(val,1+tm.get(val));
        else tm.put(val,1);
    }
    static void remove(TreeMap<Integer,Integer> tm,int val)
    {
        int v = tm.get(val);
        if(v>1)
            tm.put(val, v-1);
        else tm.remove(val);
    }
    static void add(Map<Integer,Integer> map,int val)
    {
        if(map.containsKey(val))
            map.put(val,1+map.get(val));
        else map.put(val,1);
    }
    static void remove(Map<Integer,Integer> map,int val)
    {
        int v = map.get(val);
        if(v==1)
            map.remove(val);
        else map.put(val,v-1);
    }
    static class Pair implements Comparable<Pair>
    {
        int x,y;
        Pair(int x,int y)
        {
            this.x = x;
            this.y = y;
        }
        public int compareTo(Pair other)
        {
            if(other.x>this.x)
                return 1;
            else if(other.x<this.x)
                return -1;
            else 
            {
                if(other.y>this.y)
                    return 1;
                else if(other.y<this.y)
                    return -1;
                return 0;
            }
        }
        public String toString()
        {
            return "("+x+","+y+")";
        }
        public boolean equals(Object o)
        {
            if(o instanceof Pair)
            {
                Pair other = (Pair)o;
                return this.x==other.x && this.y==other.y;
            }
            return false;
        }
        public int hashCode()
        {
            return this.x+this.y;
        }
    }
    static class MyComparator implements Comparator<Pair>
    {
        public int compare(Pair a,Pair b)
        {
           if(a.x>b.x)
               return 1;
           else if(a.x<b.x)
               return -1;
           else if(a.y>b.y)
               return 1;
           else if(a.y<b.y)
               return -1;
           return 0;
        }
    }
    static class TupleD implements Comparable<TupleD>
    {
        int u,v;
        long w;
        TupleD(int u,int v,long w)
        {
            this.u = u;
            this.v = v;
            this.w = w;
        }
        public int compareTo(TupleD other)
        {
            if(this.w>other.w)
                return 1;
            else if(this.w==other.w)
                return 0;
            else return -1;
        }
        public String toString()
        {
            return "("+u+","+v+","+w+")";
        }
    }
        static class TupleI implements Comparable<TupleI>
    {
        int u,v,w;
        TupleI(int u,int v,int w)
        {
            this.u = u;
            this.v = v;
            this.w = w;
        }
        public int compareTo(TupleI other)
        {
            if(this.w>other.w)
                return 1;
            else if(this.w==other.w)
                return 0;
            else return -1;
        }
        public String toString()
        {
            return "("+u+","+v+","+w+")";
        }
    }
    static class TupleL implements Comparable<TupleL>
    {
        long u,v,w;
        TupleL(long u,long v,long w)
        {
            this.u = u;
            this.v = v;
            this.w = w;
        }
        public int compareTo(TupleL other)
        {
            if(this.w>other.w)
                return 1;
            else if(this.w==other.w)
                return 0;
            else return -1;
        }
        public String toString()
        {
            return "("+u+","+v+","+w+")";
        }
    }
    static class DSU
    {
        int arr[];
        int size[];
        DSU(int n)
        {
            size = new int[n];
            arr = new int[n];
            for(int i=0;i<n;++i)
            {
                arr[i] = i;
                size[i]++;
            }
        }
        int getroot(int A)
        {
            if(arr[A]==A)
                return A;
            return arr[A] = getroot(arr[A]);
        }
        boolean union(int A,int B)
        {
            int rootA = getroot(A);
            int rootB = getroot(B);
            if(rootA==rootB)
                return false;
            if(size[rootB]>size[rootA])
            {
                size[rootB]+=size[rootA];
                arr[rootA] = rootB;
            }
            else
            {
                size[rootA]+=size[rootB];
                arr[rootB] = rootA;
            }
            return true;
        }
    }
    static long gcd(long a,long b)
    {
        if(b==0)
            return a;
        return gcd(b,a%b);
    }
    static long modpow(long a,long b,long m)
    {
        if(b==0)
            return 1;
        if((b&1)==0)
            return modpow((a*a)%m,b>>1,m);
        else return (modpow((a*a)%m,b>>1,m)*a)%m;
    }
     static TupleL EEA(long A,long B)
    {
        if(B==0)
            return new TupleL(A,1,0);
        TupleL t = EEA(B,A%B);
        return new TupleL(t.u,t.w,t.v-(A/B)*t.w);
    }
     static long mulmodin(long A,long M)
     {
         long x = EEA(A,M).v;
         return (x+M)%M;
     } 
     static long divide(long A,long B,long M)       //Applicable only if A%B==0
     {  
         A%=M;
         long invB = mulmodin(B,M);
         return (A*invB)%M;
     }
     static long subtract(long A,long B,long M)
     {
         A%=M;
         B%=M;
         if(A>=B)
             return A-B;
         return (A-B+M)%M;
     }
    static class SegmentTree
    {
        int tree[];
        int arr[];
        int n;
        SegmentTree(int n,int a[])
        {  
            this.n = n;
            arr =  new int[n];
            for(int i=0;i<n;++i)
                arr[i] = a[i];
            int sz = (int)pow(2,(int)ceil(log(n)/log(2)));
            sz*=2;
            tree = new int[sz];
            build(0,n-1,1);
        }
        final void build(int low,int high,int treein)
        {
            if(low==high)
            {
                tree[treein] = arr[low];
            }
            else
            {
                int mid = (low+high)>>1;
                build(low,mid,2*treein);
                build(mid+1,high,2*treein+1);
                tree[treein] = min(tree[2*treein],tree[2*treein+1]);
            }
        }
        final void update(int index,int treein,int low,int high,int val)
        {
            if(low==high)
            {
                arr[index]=tree[treein]=val;
            }
            else
            {
                int mid = (low+high)>>1;
                if(index<=mid)
                    update(index,2*treein,low,mid,val);
                else update(index,2*treein+1,mid+1,high,val);
                tree[treein] = min(tree[2*treein],tree[2*treein+1]);
            }
        }
        final void update(int index,int val)
        {
            update(index,1,0,n-1,val);
        }
        final int query(int low,int high,int l,int r,int treein)
        {
            if(l<=low && high<=r)
                return tree[treein];
            else if(low>r || high<l)
                return Integer.MAX_VALUE;
            int mid = (low+high)>>1;
            int a = query(low,mid,l,r,2*treein);
            int b = query(mid+1,high,l,r,2*treein+1);
            return min(a,b);
        }
        final int query(int l,int r)
        {
            return query(0,n-1,l,r,1);
        }
        final int query(int index)
        {
            return query(0,n-1,0,index,1);
        }
    }
    static class MyFileReader                                          //File input template
    {
        StringTokenizer st;
        BufferedReader br;
        MyFileReader() throws IOException
        {
            br = new BufferedReader(new FileReader("C://Users/Aman deep/Desktop/input.txt"));
        }
        String nextLine() throws IOException
        {
            return br.readLine();
        }
        String next() throws IOException
        {
            if(st==null || !st.hasMoreTokens())
                st = new StringTokenizer(nextLine());
            return st.nextToken();
        }
        int nextInt() throws IOException
        {
            return Integer.parseInt(next());
        }
        long nextLong() throws IOException
        {
            return Long.parseLong(next());
        }
        double nextDouble() throws IOException
        {
            return Double.parseDouble(next());
        }
    }
        static class MyScanner    //Strings and numbers both reader
    {
        StringTokenizer st;
        BufferedReader br;
        MyScanner() throws IOException
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String nextLine() throws IOException
        {
            return br.readLine();
        }
        String next() throws IOException
        {
            if(st==null || !st.hasMoreTokens())
                st = new StringTokenizer(nextLine());
            return st.nextToken();
        }
        int nextInt() throws IOException
        {
            return Integer.parseInt(next());
        }
        long nextLong() throws IOException
        {
            return Long.parseLong(next());
        }
        double nextDouble() throws IOException
        {
            return Double.parseDouble(next());
        }
    }
}
