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

public class ai {
    InputStream is;
    PrintWriter out;
    long mod = (long)(1e9 + 7), inf = (long)(3e18);
    int cnt[];
    void solve() throws IOException {
        int t = ni();
        while(t>0){
            t--;
            int n = ni();
            int k = ni();
            long ans = 0;
            int arr[] = sieve(n+1);
//            for(int i=1;i<n;i++)System.out.print(arr[i]+" ");
            if(n%2==0){
                ans = n*1l + 2l*k;
            }
            else{
                ans = n*1l + 2l * (k-1) + arr[n];
            }
            System.out.println(ans);
        }
    }
    public void build(long arr[],long brr[],int a[],int n,int l,int r){
        if(l==r){
            arr[n] = brr[n] = a[l];
        }
        else{
            int mid = (l+r)/2;
            build(arr,brr,a,2*n,l,mid);
            build(arr,brr,a,2*n+1,mid+1,r);
            arr[n] = arr[2*n] + arr[2*n+1];
            brr[n] = Math.max(brr[2*n],brr[2*n+1]);
        }
    }
    public long sum(long arr[],int l,int r,int n,int start,int end){
        if(start>end)return 0;
        if(l==start && r==end){
            return arr[n];
        }
        int mid = (l+r)/2;
        return sum(arr,l,mid,2*n,start,Math.min(end,mid)) + sum(arr,mid+1,r,2*n+1,Math.max(mid+1,start),end);
    }
    public void increment(long arr[],long brr[],int n,int l,int r,int tl,int tr,HashMap<Long,Integer> map){
        if(l>r)return;
        if(l==r && tl==tr){
            arr[n] = map.get(arr[n]);
            brr[n] = map.get(brr[n]);
        }
        else{
            int mid = (tl+tr)/2;
            if(brr[2*n]>2)
            increment(arr,brr,2*n,l,Math.min(r,mid),tl,mid,map);
            if(brr[2*n+1]>2)
            increment(arr,brr,2*n+1,Math.max(l,mid+1),r,mid+1,tr,map);
            arr[n] = arr[2*n] + arr[2*n+1];
            brr[n] = Math.max(brr[2*n],brr[2*n+1]);
        }
    }
    public int[] sieve(int n){
        int []ans = new int[n];
        ans[1]=1;
        int i=2;
        while(i<n){
            if(ans[i]==0){
                int j=2*i;
                ans[i]=i;
                while(j<n){
                    if(ans[j]==0)
                        ans[j] = i;
                    j+=i;
                }
            }
            i++;
        }
        return ans;
    }
    public static void main(String[] args)throws Exception { new ai().run(); }
    void run() throws Exception {
        is = System.in;
        out = new PrintWriter(System.out);
        solve();
        out.flush();
    }

    byte input[] = new byte[1024];
    int len = 0, ptr = 0;

    int readByte() {
        if(ptr >= len) { ptr = 0;
            try { len = is.read(input); }
            catch(IOException e) { throw new InputMismatchException(); }
            if(len <= 0) { return -1; }
        } return input[ptr++];
    }
    boolean isSpaceChar(int c) { return !( c >= 33 && c <= 126 ); }
    int skip() {
        int b = readByte();
        while(b != -1 && isSpaceChar(b)) { b = readByte(); }
        return b;
    }

    char nc() { return (char)skip(); }
    String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while(!isSpaceChar(b)) { sb.appendCodePoint(b); b = readByte(); }
        return sb.toString();
    }
    String nLine() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while( !(isSpaceChar(b) && b != ' ') ) { sb.appendCodePoint(b); b = readByte(); }
        return sb.toString();
    }
    int ni() {
        int n = 0, b = readByte();
        boolean minus = false;
        while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')) { b = readByte(); }
        if(b == '-') { minus = true; b = readByte(); }
        if(b == -1) { return -1; }  //no input
        while(b >= '0' && b <= '9') { n = n * 10 + (b - '0'); b = readByte(); }
        return minus ? -n : n;
    }
    long nl() {
        long n = 0L;    int b = readByte();
        boolean minus = false;
        while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')) { b = readByte(); }
        if(b == '-') { minus = true; b = readByte(); }
        while(b >= '0' && b <= '9') { n = n * 10 + (b - '0'); b = readByte(); }
        return minus ? -n : n;
    }

    double nd() { return Double.parseDouble(ns()); }
    float nf() { return Float.parseFloat(ns()); }
    int[] na(int n) {
        int a[] = new int[n];
        for(int i = 0; i < n; i++) { a[i] = ni(); }
        return a;
    }
    char[] ns(int n) {
        char c[] = new char[n];
        int i, b = skip();
        for(i = 0; i < n; i++) {
            if(isSpaceChar(b)) { break; }
            c[i] = (char)b; b = readByte();
        } return i == n ? c : Arrays.copyOf(c,i);
    }
}