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.*;
import java.math.*;
import java.lang.*;

import static java.lang.Math.*;

public class Cf131 implements Runnable 
{
    static class InputReader 
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        public InputReader(InputStream stream) 
        {
            this.stream = stream;
        }
        
        public int read()
        {
            if (numChars==-1) 
                throw new InputMismatchException();
            
            if (curChar >= numChars) 
            {
                curChar = 0;
                try
                {
                    numChars = stream.read(buf);
                }
                catch (IOException e)
                {
                    throw new InputMismatchException();
                }
                
                if(numChars <= 0)               
                    return -1;
            }
            return buf[curChar++];
        }
    
        public String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }    
            return str;
        }
        public int nextInt() 
        {
            int c = read();
            
            while(isSpaceChar(c)) 
                c = read();
        
            int sgn = 1;
        
            if (c == '-') 
            {
                sgn = -1;
                c = read();
            }
            
            int res = 0;
            do
            {
                if(c<'0'||c>'9') 
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c)); 
        
            return res * sgn;
        }
        
        public long nextLong() 
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            long res = 0;
            
            do 
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }    
            while (!isSpaceChar(c));
                return res * sgn;
        }
        
        public double nextDouble() 
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') 
            {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') 
            {
                c = read();
                double m = 1;
                while (!isSpaceChar(c))
                {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }
    
        public String readString() 
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do 
            {
                res.appendCodePoint(c);
                c = read();
            } 
            while (!isSpaceChar(c));
            
            return res.toString();
        }
    
        public boolean isSpaceChar(int c) 
        {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    
        public String next()
        {
            return readString();
        }
        
        public interface SpaceCharFilter
        {
            public boolean isSpaceChar(int ch);
        }
    }
    public static void main(String args[]) throws Exception 
    {
        new Thread(null, new Cf131(),"Main",1<<27).start();
    }
    
    static class Pair{
        int nod;
        int ucn;
        
        
        Pair(int nod,int ucn){
            this.nod=nod;
            this.ucn=ucn;
            
        }
        
    public static Comparator<Pair> wc = new Comparator<Pair>(){
        public int compare(Pair e1,Pair e2){
            
            //reverse order
            if (e1.ucn < e2.ucn) 
                return 1;  // 1 for swaping.
            else if (e1.ucn > e2.ucn) 
                return -1; 
            else{
                // if(e1.siz>e2.siz)
                //     return 1;
                // else
                //     return -1;
                return 0;
            } 
        }
    };	
    }

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


    ////recursive BFS
    public static int bfsr(int s,ArrayList<Integer>[] a,int[] dist,boolean[] b,int[] pre){
        b[s]=true;
        int p = 0;
        int t = a[s].size();
        for(int i=0;i<t;i++){
            int x = a[s].get(i);
            if(!b[x]){
                dist[x] = dist[s] + 1;
                p+= (bfsr(x,a,dist,b,pre)+1);
            }
        }
        pre[s] = p;
        return p;
    }

//// iterative BFS
    public static int bfs(int s,ArrayList<Integer>[] a,int[] dist,boolean[] b,PrintWriter w){
        b[s]=true;
        int siz = 0;
        
        Queue<Integer> q = new LinkedList<>();
        q.add(s);
        while(q.size()!=0){
            int i=q.poll();
        //    w.println(" #"+i+"# ");
            Iterator<Integer> it =a[i].listIterator();
            int z=0;
            while(it.hasNext()){
                z=it.next();
               // w.println("#"+i+" "+z);
                if(!b[z]){
                //    w.println("* "+z+" *");
                    b[z]=true;
                    dist[z] = dist[i] + 1;
                 //   w.print("*");
                   // w.println(i+" "+z);
                    siz++;
                //    x.add(z);
                //    w.println("@ "+x.get(x.size()-1)+" @");
                    q.add(z);
                }
            }   
        
        }
        return siz;
    }







//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////


    public void run()
    {
        InputReader sc = new InputReader(System.in);
        PrintWriter w = new PrintWriter(System.out);
        // int defaultValue=0;
        // int[] a = new int[15000003];
        // for(int i=2;i<a.length;i++){
        //     boolean f = true;
        //     for(int j=2;j<=(int)(double)Math.sqrt(i);j++){
        //         if(i%j==0){a[i]=j;f = false;break;}

        //     }
        //     if(f)a[i] = i;
        // }

        int t = sc.nextInt();
        while(t-->0){
        
            int n = sc.nextInt();
            int k = sc.nextInt();
            int ans = n;
            while(k>0){
               if(ans%2==0){ans+=(2*k);k=0;break;}
               else{
                boolean f = true;
                    for(int j=2;j<=(int)(double)Math.sqrt(ans);j++){
                        if(ans%j==0){ans+=j;f = false;break;}
        
                    }
                    if(f)ans+=ans;
               }
               k--;
            }
            w.println(ans);
            
           
        }    
        w.flush();
        w.close();



        
        
    }

}