Let's assume that 
 -  *v*(*n*) is the largest prime number, that does not exceed *n*;-  *u*(*n*) is the smallest prime number strictly greater than *n*. 
Find <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/9efda33382293068ce21371b950297a1d3ac3212.png" style="max-width: 100.0%;max-height: 100.0%;"/>.
The first line contains integer *t* (1 ≤ *t* ≤ 500) — the number of testscases. 

Each of the following *t* lines of the input contains integer *n* (2 ≤ *n* ≤ 10<sup class="upper-index">9</sup>).
def getdistance(orvertice, dstvertice):
    distance = 0
    actual = orvertice
    while not actual is dstvertice:
        if actual['Parent'] == -1:
            raise ValueError('Not a descendent')
        actual = actual['Parent']
        distance += 1
    return distance


vertices = list()
input()
vertices.append({'Parent': -1, 'Value': 0})
for parent in input().split(' '):
    vertices.append({'Parent': vertices[int(parent)-1], 'Value': 0})
for i in range(0, int(input())):
    query = input().split(' ')
    if int(query[0]) == 1:
        for vertice in vertices:
            try:
                vertice['Value'] += int(query[2]) - int(query[3]) * \
                    getdistance(vertice, vertices[int(query[1]) - 1])
            except Exception as e:
                pass
    else:
        print(vertices[int(query[1])-1]['Value'] % 1000000007)
