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.
from collections import defaultdict, OrderedDict, Counter
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
# import numpy as np
from queue import Queue, PriorityQueue
from heapq import *
from statistics import *
from math import sqrt, log10, log2, log, gcd,ceil, floor
import fractions
import copy
from copy import deepcopy
import sys
import io

sys.setrecursionlimit(10000)
import math
import os
import bisect
import collections

mod = int(pow(10, 9)) + 7
import random
from random import *
import time
from time import time;
import timeit
from timeit import timeit

import itertools
from itertools import  combinations,permutations,combinations_with_replacement,product


def ncr(n, r, p=mod):
    num = den = 1
    for i in range(r):
        num = (num * (n - i)) % p
        den = (den * (i + 1)) % p
    return (num * pow(den,
                      p - 2, p)) % p


def normalncr(n, r):
    r = min(r, n - r)
    count = 1;
    for i in range(n - r, n + 1):
        count *= i;

    for i in range(1, r + 1):
        count //= i;
    return count


inf = float("inf")
adj = defaultdict(set)
visited = defaultdict(int)


def addedge(a, b):
    adj[a].add(b)
    adj[b].add(a)


def bfs(v):
    q = Queue()
    q.put(v)
    visited[v] = 1
    while q.qsize() > 0:
        s = q.get_nowait()
        print(s)
        for i in adj[s]:
            if visited[i] == 0:
                q.put(i)
                visited[i] = 1


def dfs(v, visited):
    if visited[v] == 1:
        return;
    visited[v] = 1

    print(v)
    for i in adj[v]:
        dfs(i, visited)


# a9=pow(10,6)+10
# prime = [True for i in range(a9 + 1)]
# def SieveOfEratosthenes(n):
#     p = 2
#     while (p * p <= n):
#         if (prime[p] == True):
#             for i in range(p * p, n + 1, p):
#                 prime[i] = False
#         p += 1
# SieveOfEratosthenes(a9)
# prime_number=[]
# for i in range(2,a9):
#     if prime[i]:
#         prime_number.append(i)
def reverse_bisect_right(a, x, lo=0, hi=None):
    if lo < 0:
        raise ValueError('lo must be non-negative')
    if hi is None:
        hi = len(a)
    while lo < hi:
        mid = (lo + hi) // 2
        if x > a[mid]:
            hi = mid
        else:
            lo = mid + 1
    return lo


def reverse_bisect_left(a, x, lo=0, hi=None):
    if lo < 0:
        raise ValueError('lo must be non-negative')
    if hi is None:
        hi = len(a)
    while lo < hi:
        mid = (lo + hi) // 2
        if x >= a[mid]:
            hi = mid
        else:
            lo = mid + 1
    return lo


def get_list():
    return list(map(int, input().split()))

def make_list(m):
    m+=list(map(int, input().split()))

def get_str_list_in_int():
    return [int(i) for i in list(input())]


def get_str_list():
    return list(input())


def get_map():
    return map(int, input().split())


def input_int():
    return int(input())


def matrix(a, b):
    return [[0 for i in range(b)] for j in range(a)]


def swap(a, b):
    return b, a


def find_gcd(l):
    a = l[0]
    for i in range(len(l)):
        a = gcd(a, l[i])
    return a;


def is_prime(n):
    sqrta = int(sqrt(n))
    for i in range(2, sqrta + 1):
        if n % i == 0:
            return 0;
    return 1;


def prime_factors(n):
    l=[]
    while n % 2 == 0:
        l.append(2)
        n//=2
    sqrta = int(sqrt(n))

    for i in range(3, sqrta + 1, 2):
        while n % i == 0:
            n//=i;
            l.append(i)
    if n>2:
        l.append(n)
    return l

def p(a):
    if type(a) == str:
        print(a + "\n")
    else:
        print(str(a) + "\n")


def ps(a):
    if type(a) == str:
        print(a)
    else:
        print(str(a))


def kth_no_not_div_by_n(n, k):
    return k + (k - 1) // (n - 1)


def forward_array(l):
    """
    returns the forward index where the elemetn is just greater than that element
    [100,200] gives [1,2]
    because element at index 1 is greater than 100 and nearest
    similarly if it is largest then it outputs n
    :param l:
    :return:
    """
    n = len(l)
    stack = []
    forward = [0] * n
    for i in range(len(l) - 1, -1, -1):
        while len(stack) and l[stack[-1]] < l[i]:
            stack.pop()
        if len(stack) == 0:
            forward[i] = len(l);
        else:
            forward[i] = stack[-1]
        stack.append(i)
    return forward;


def backward_array(l):
    n = len(l)
    stack = []
    backward = [0] * n
    for i in range(len(l)):
        while len(stack) and l[stack[-1]] < l[i]:
            stack.pop()
        if len(stack) == 0:
            backward[i] = -1;
        else:
            backward[i] = stack[-1]
        stack.append(i)
    return backward


def char(a):
    return chr(a + 97)


def get_length(a):
    return 1 + int(log10(a))


def issq(n):
    sqrta = int(n ** 0.5)
    return sqrta ** 2 == n;


def ceil(a,b):
    return int((a+b-1)/b)

def equal_sum_partition(arr,n):
    sum = 0
    for i in range(n):
        sum += arr[i]
    if sum % 2 != 0:
        return False

    part = [[True for i in range(n + 1)]
            for j in range(sum // 2 + 1)]

    for i in range(0, n + 1):
        part[0][i] = True

    for i in range(1, sum // 2 + 1):
        part[i][0] = False

    for i in range(1, sum // 2 + 1):

        for j in range(1, n + 1):
            part[i][j] = part[i][j - 1]

            if i >= arr[j - 1]:
                part[i][j] = (part[i][j] or
                              part[i - arr[j - 1]][j - 1])

    return part[sum // 2][n]

def bin_sum_array(arr,n):
    for i in range(n):
        if arr[i]%2==1:
            return i+1
    binarray=[list(reversed(bin(i)[2:])) for i in arr]
    new_array=[0 for i in range(32)]
    for i in binarray:
        for j in range(len(i)):
            if i[j]=='1':
                new_array[j]+=1
    return new_array
def ispalindrome(s):
    return s==s[::-1]
nc = "NO"
yc = "YES"
ns = "No"
ys = "Yes"
def yesno(a):
    print(yc if a else nc)
def reduce(dict,a):
    dict[a]-=1;
    if dict[a]==0:
        dict.pop(a)
# import math as mt
# MAXN=10**7
# spf = [0 for i in range(MAXN)]
# def sieve():
#     spf[1] = 1
#     for i in range(2, MAXN):
#         # marking smallest prime factor
#         # for every number to be itself.
#         spf[i] = i
#
#         # separately marking spf for
#     # every even number as 2
#     for i in range(4, MAXN, 2):
#         spf[i] = 2
#
#     for i in range(3, mt.ceil(mt.sqrt(MAXN))):
#
#         # checking if i is prime
#         if (spf[i] == i):
#
#             # marking SPF for all numbers
#             # divisible by i
#             for j in range(i * i, MAXN, i):
#
#                 # marking spf[j] if it is
#                 # not previously marked
#                 if (spf[j] == j):
#                     spf[j] = i
# def getFactorization(x):
#     ret = list()
#     while (x != 1):
#         ret.append(spf[x])
#         x = x // spf[x]
#
#     return ret
# sieve()


# if(os.path.exists('input.txt')):
#     sys.stdin = open("input.txt","r") ; sys.stdout = open("output.txt","w")


# input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
# input=stdin.readline
# print=stdout.write

def get_smallest(n):
    for i in range(2,int(n**0.5)+1):
        if n%i==0:
            return i;
    return n;
t=int(input())
for i in range(t):
    n,k=get_list()
    smallest=get_smallest(n)
    ans=n+smallest+(k-1)*2
    print(ans)







