<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.
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Template implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            String filename = "";
            if (filename.isEmpty()) {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                in = new BufferedReader(new FileReader(filename + ".in"));
                out = new PrintWriter(filename + ".out");
            }
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine(), " :");
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    int[] readIntArray(int size) throws IOException {
        int[] res = new int[size];
        for (int i = 0; i < size; i++) {
            res[i] = readInt();
        }
        return res;
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    <T> List<T>[] createGraphList(int size) {
        List<T>[] list = new List[size];
        for (int i = 0; i < size; i++) {
            list[i] = new ArrayList<>();
        }
        return list;
    }

    public static void main(String[] args) {
        new Template().run();
        //new Thread(null, new Template(), "", 1l * 200 * 1024 * 1024).start();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10)
                + " KB");
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            if (System.getProperty("ONLINE_JUDGE") == null) {
                time();
                memory();
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    int[] plist;

    void solve() throws IOException {
        List<Integer> primes = new ArrayList<>();
        for (int i = 2; i < 1000; i++) {
            if (BigInteger.valueOf(i).isProbablePrime(10)) primes.add(i);
        }
        plist = new int[primes.size()];
        for (int i = 0; i < plist.length; i++) {
            plist[i] = primes.get(i);
        }
        int n = readInt();
        while (n-- > 0) {
            int a = readInt();
            int b = readInt();
            out.println(yes2(a, b) ? "Yes" : "No");
        }


//
//        for (int f=1;f<=10000;f++) {
//            System.err.println(f);
//            for (int s=1;s<=10000;s++) {
//                if (yes2(f,s) != can(f,s)) throw new RuntimeException();
//            }
//        }
//
//
//        Random random = new Random(5);
//
//        while (true) {
//            int a = random.nextInt(1000000000) + 1;
//            int b = random.nextInt(1000000000) + 1;
//            if (yes2(a, b) != can(a, b)) throw new RuntimeException(a + " " + b);
//        }

//        n = 350000;
//        int bigPrime = BigInteger.valueOf(1000000000 - 100000).nextProbablePrime().intValue();
//        System.err.println(bigPrime);
//        while (n-- > 0) {
//            int a = bigPrime;//random.nextInt(1000000000) + 1;
//            int b = bigPrime;//random.nextInt(1000000000) + 1;
//            out.println(yes2(a, b) ? "Yes" : "No");
//        }
    }

    boolean can(int x, int y) {
        for (int i = 2; i * i <= x; i++) {
            if (x % i == 0) {
                int cnt1 = 0;
                while (x % i == 0) {
                    cnt1++;
                    x /= i;
                }

                int cnt2 = 0;

                while (y % i == 0) {
                    cnt2++;
                    y /= i;
                }

                if (!ok(cnt1, cnt2)) return false;
            }
        }
        if (x > 1) {
            int cnt1 = 1;
            int cnt2 = 0;
            while (y % x == 0) {
                y /= x;
                cnt2++;
            }
            if (!ok(cnt1, cnt2)) return false;
        }

        return y == 1;
    }

    int gcd(int x, int y) {
        if (x == 0) return y;
        return gcd(y % x, x);
    }

    boolean yes2(int x, int y) {
        int g = gcd(x, y);
        int remX = x / g;
        int remY = y / g;
        if (g % remX != 0) return false;
        g /= remX;
        if (g % remY != 0) return false;
        g /= remY;

        for (int i : plist) {
            if (g % i == 0) {
                int cnt = 0;
                while (g % i == 0) {
                    cnt++;
                    g /= i;
                }
                if (cnt % 3 != 0) return false;
            }
        }
        return g == 1;
    }

    boolean ok(int cnt1, int cnt2) {
        if (cnt1 > cnt2) return ok(cnt2, cnt1);

        int diff = cnt2 - cnt1;
        if (diff > cnt1) return false;

        int threes = cnt1 - diff;
        if (threes % 3 != 0) return false;
        return true;
    }


}