Orac is studying number theory, and he is interested in the properties of divisors.

For two positive integers a and b, a is a divisor of b if and only if there exists an integer c, such that a⋅ c=b.

For n ≥ 2, we will denote as f(n) the smallest positive divisor of n, except 1.

For example, f(7)=7,f(10)=2,f(35)=5.

For the fixed integer n, Orac decided to add f(n) to n. 

For example, if he had an integer n=5, the new value of n will be equal to 10. And if he had an integer n=6, n will be changed to 8.

Orac loved it so much, so he decided to repeat this operation several times.

Now, for two positive integers n and k, Orac asked you to add f(n) to n exactly k times (note that n will change after each operation, so f(n) may change too) and tell him the final value of n.

For example, if Orac gives you n=5 and k=2, at first you should add f(5)=5 to n=5, so your new value of n will be equal to n=10, after that, you should add f(10)=2 to 10, so your new (and the final!) value of n will be equal to 12.

Orac may ask you these queries many times.

Input

The first line of the input is a single integer t\ (1≤ t≤ 100): the number of times that Orac will ask you.

Each of the next t lines contains two positive integers n,k\ (2≤ n≤ 10^6, 1≤ k≤ 10^9), corresponding to a query by Orac.

It is guaranteed that the total sum of n is at most 10^6. 

Output

Print t lines, the i-th of them should contain the final value of n in the i-th query by Orac.

Example

Input


3
5 1
8 2
3 4


Output


10
12
12

Note

In the first query, n=5 and k=1. The divisors of 5 are 1 and 5, the smallest one except 1 is 5. Therefore, the only operation adds f(5)=5 to 5, and the result is 10.

In the second query, n=8 and k=2. The divisors of 8 are 1,2,4,8, where the smallest one except 1 is 2, then after one operation 8 turns into 8+(f(8)=2)=10. The divisors of 10 are 1,2,5,10, where the smallest one except 1 is 2, therefore the answer is 10+(f(10)=2)=12.

In the third query, n is changed as follows: 3 → 6 → 8 → 10 → 12.
import java.io. *;
import java.util.*;
public class Main {

    static int visited[];
    static ArrayList<ArrayList<Integer>> adjlist;
    static class edge implements  Comparator<edge>{
        int dest;
        int cost;

        public edge(int dest, int cost) {
            this.dest = dest;
            this.cost = cost;
        }

        @Override
        public int compare(edge o1, edge o2) {
            return o1.cost-o2.cost;
        }
    }

    static int dist[];
    static int nodesinSubtree[];
    static int color[];
    static ArrayList<Integer> res1;
    static ArrayList<Integer> res2;

    static class Graph{
        int V;
        ArrayList<ArrayList<edge>> adj;
        PriorityQueue<edge> pq;

        public Graph(int V){
            this.V = V;
            adj = new ArrayList<>(V);
            pq = new PriorityQueue<>(V,new edge(-1,-1));
            dist = new int[V];
            nodesinSubtree = new int[V];
            color = new int[V];
            Arrays.fill(color,-1);
            for(int i=0; i<V; i++){
                dist[i] = Integer.MAX_VALUE;
                adj.add(i,new ArrayList<>());
            }
        }

        void addedge(int u, int v, int w ){
            adj.get(u).add(new edge(v,w));
            //adj.get(v).add(new edge(u,w));
        }

        void rDfs(int src, int e){
            //nodes in a subtree
            nodesinSubtree[src] = 1;
            for(int i=0; i<adj.get(src).size(); i++){
                if(adj.get(src).get(i).dest==e){
                    continue;
                }
                rDfs(adj.get(src).get(i).dest,src);
                nodesinSubtree[src]+=nodesinSubtree[adj.get(src).get(i).dest];
            }
        }




        void uBFS(int src){
            Queue<edge> q = new LinkedList<>();
            int color[] = new int[V];
            q.add(new edge(src,0));
            color[src] = 1;
            while (!q.isEmpty()){
                int u = q.poll().dest;
                for(int i=0; i<adj.get(u).size(); i++){
                    if(color[adj.get(u).get(i).dest]==0){
                        color[adj.get(u).get(i).dest] = color[u]==1?2:1;
                        q.add(new edge(adj.get(u).get(i).dest,0));
                    }
                }
            }
        }

        int DFS(int src){
            Stack<edge> st = new Stack<>();
            boolean visited[] = new boolean[V];
            visited[src] = true;
            st.push(new edge(src,0));
            dist[src] = 0;
            color[src] = 0;
            while (!st.empty()){
                int u = st.peek().dest;
                st.pop();
                for(int i=0; i<adj.get(u).size(); i++){
                    if(color[adj.get(u).get(i).dest]==-1 ) {
                        if (color[u] == 0) {
                            color[adj.get(u).get(i).dest] = 1;
                        } else {
                            color[adj.get(u).get(i).dest] = 0;
                        }
                        st.push(new edge(adj.get(u).get(i).dest,0));
                    }else{
                        if(color[u]==0 && color[adj.get(u).get(i).dest]==0){
                            return -1;
                        }
                        if(color[u]==1 && color[adj.get(u).get(i).dest]==1){
                            return -1;
                        }
                    }
                }
            }
            return 0;
        }
    }


/*
        void dijkstra(int src){
            for(int i=0; i<V; i++){
                dist[i] = Integer.MAX_VALUE;
            }
            dist[src] = 0;
            pq.add(new edge(src,0));
            while (!pq.isEmpty()){
                int u = pq.poll().dest;
                for(int i=0; i<adj.get(u).size(); i++){
                    int v = adj.get(u).get(i).dest;
                    int w = adj.get(u).get(i).cost;
                    if(dist[u]+w<=dist[v]){
                        dist[v] = dist[u] + w;
                        pq.add(new edge(v,dist[v]));
                    }
                }
            }

        }


    }

 */



    static  int I[];
    static  int  L[];
    static void LIS(int n, int arr[]){
        I = new int[n+1];
        L = new int[n];
        I[0] = Integer.MIN_VALUE;
        for(int i=1;i<=n; i++){
            I[i] = Integer.MAX_VALUE;
        }
        int lisLength = 1;

        for(int i=n-1; i>=0; i--) {
            int low = 1;
            int high = lisLength;
            int mid = 0;
            while (low < high) {
                mid = (low + high) >> 1;
                if (I[mid] <= arr[i]) {
                    high = mid;
                } else {
                    low = mid + 1;
                }
            }
            I[high] = arr[i];
            L[i] = high;
            if(lisLength<=high){
                lisLength++;
            }
        }
    }

    public static long gcd(long a, long b)
    {
        if (a == 0)
            return b;

        return gcd(b%a, a);
    }

    public static long lcm(long a, long b)
    {
        return (a*b)/gcd(a, b);
    }

    static long nCr(long n, long r)
    {
        return fact(n) / (fact(r) * fact(n - r));
    }

    // Returns factorial of n
    static long fact(long n)
    {
        long res = 1;
        for (int i = 2; i <= n; i++)
            res = (res * i)%MOD;
        return res;
    }


    static int MOD = 1000000007;
    static int power(int x, int y, int p)
    {

        // Initialize result
        int res = 1;

        // Update x if it is more than or
        // equal to p
        x = x % p;

        while (y > 0)
        {

            // If y is odd, multiply x
            // with result
            if (y % 2 == 1)
                res = (res * x) % p;

            // y must be even now
            y = y >> 1; // y = y/2
            x = (x * x) % p;
        }

        return res;
    }

    // Returns n^(-1) mod p
    static int modInverse(int n, int p)
    {
        return power(n, p-2, p);
    }

    static int nCrModPFermat(int n, int r,
                             int p)
    {

        if (r == 0)
            return 1;


        int[] fac = new int[n+1];
        fac[0] = 1;

        for (int i = 1 ;i <= n; i++)
            fac[i] = fac[i-1] * i % p;

        return (fac[n]* modInverse(fac[r], p)
                % p * modInverse(fac[n-r], p)
                % p) % p;
    }
    public static long log2(long N)
    {

        long result = (long)(Math.log(N) / Math.log(2));

        return result;
    }
    static class team implements Comparator<team>{
        long id;
        int m;

        public team(long id, int m) {
            this.id = id;
            this.m = m;
        }

        @Override
        public int compare(team o1, team o2) {
            return o2.m-o1.m;
        }
    }

    static int findParent(int dsu[], int parent){
        if(dsu[parent]<0){
            return parent;
        }
        return findParent(dsu,dsu[parent]);
    }

    public static double round(double value, int places) {
        if (places < 0) throw new IllegalArgumentException();

        long factor = (long) Math.pow(10, places);
        value = value * factor;
        long tmp = Math.round(value);
        return (double) tmp / factor;
    }

    static boolean isPrime(long n){
        if(n<=2){
            return true;
        }
        for(int i =2; i*i<=n; i++){
            if(n%i==0){
                return false;
            }
        }
        return true;
    }

    static long lowestDiv(long n){
        if(n<=2 || isPrime(n)){
            return n;
        }
        for(int i =2; i*i<=n; i++){
            if(n%i==0 && isPrime(i)){
                return i;
            }
        }
        return n;
    }

    static int cnt[];

    public static void main(String[] args) {
        FastReader sc = new FastReader(System.in);
        PrintWriter pw = new PrintWriter(System.out);

        int testcase = sc.nextInt();


        while (testcase-->0) {

            long n = sc.nextLong();

            long k = sc.nextLong();

            long div = 0;
            while (k>0 && div!=2) {
                    k--;
                if (isPrime(n)) {
                    n*=2;
                }else {
                    div = lowestDiv(n);
                    n += div;
                }
            }

            if(div==2){
                    n+=(k*div);
            }


            pw.println(n);

        }



        pw.close();

    }

    static void debug(Object...obj) {
        System.err.println(Arrays.deepToString(obj));
    }

    static class FastReader {
        InputStream is;
        private byte[] inbuf = new byte[1024];
        private int lenbuf = 0, ptrbuf = 0;

        public FastReader(InputStream is) {
            this.is = is;
        }

        public int readByte(){
            if(lenbuf == -1)throw new InputMismatchException();
            if(ptrbuf >= lenbuf){
                ptrbuf = 0;
                try {
                    lenbuf = is.read(inbuf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if(lenbuf <= 0)
                    return -1;
            }
            return inbuf[ptrbuf++];
        }
        public boolean isSpaceChar(int c) {
            return !(c >= 33 && c <= 126);
        }
        public int skip() {
            int b;
            while ((b = readByte()) != -1 && isSpaceChar(b)) ;
            return b;
        }
        public String next(){
            int b = skip();
            StringBuilder sb = new StringBuilder();
            while(!(isSpaceChar(b))) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public String nextLine(){
            int b = readByte();
            StringBuilder sb = new StringBuilder();
            while(b != '\n' || b != '\r'){
                sb.appendCodePoint(b);
            }
            return sb.toString();
        }
        public int nextInt() {
            int num = 0, b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            while (true) {
                if (b >= '0' && b <= '9') {
                    num = (num << 3) + (num << 1) + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }
        public long nextLong() {
            long num = 0;
            int b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            while (true) {
                if (b >= '0' && b <= '9') {
                    num = (num << 3) + (num << 1) + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
        public char[] next(int n){
            char[] buf = new char[n];
            int b = skip(), p = 0;
            while (p < n && !(isSpaceChar(b))) {
                buf[p++] = (char) b;
                b = readByte();
            }
            return n == p ? buf : Arrays.copyOf(buf, p);
        }
        public char nextChar () {
            return (char) skip();
        }
    }
}