Chef likes to travel a lot. Every day Chef tries to visit as much cities as possible. Recently he had a quite a few trips of great Chefland for learning various recipes. Chefland had N cities numbered from 1 to N. People in Chefland are very friendly, friendliness of i-th city is given by Fi.

Before starting of each trip, Chef's initial enjoyment is 1 unit. Whenever he visits a city with friendliness Fi, his enjoyment gets multiplied by Fi units. 

City 1 is the home city of Chef. He starts each trip from his home city. Before starting a trip, he chooses a parameter R which denotes that he will start from city 1, and go to city 1 + R, then to 1 + 2 * R, then to 1 + 3 * R, till 1 + i * R such that i is largest integer satisfying 1 + i * R ≤ N.

Now, Chef wants you to help him recreate his visit of the cities. Specifically, he will ask you Q queries, each of which can be of following two types.

- 1 p f : friendliness of p-th city changes to f, i.e. Fp = f 
- 2 R   : Find out the total enjoyment Chef will have during this trip. As Chef does not like big numbers, he just asks you to output two things, first digit of the enjoyment and value of enjoyment modulo 109 + 7.

-----Input-----
There is a single test case.
First line of input contains a single integer N, denoting number of cities in Chefland.
Second line of the input contains N space separated integer - F1, F2, ..., FN, denoting the friendliness of the cities in order from 1 to N.
Next line contains an integer Q, denoting number of queries.

For each of the next Q queries, each line corresponds to one of the two types of the query. First there will be an integer denoting the type of the query, followed by the actual query. For query of type 1, there will be three space separated integers "1 p f" as defined above. For query of type 2, there will be two space separated integers "2 R ", as defined above.

-----Output-----
For each query of type 2, output two space separated integers, first digit of Chef's enjoyment in this trip followed by the value of enjoyment modulo 109 + 7.

-----Constraints-----
-  1 ≤ N, Q ≤ 105 
-  1 ≤ Fi ≤ 10^9 
-  1 ≤ f ≤ 10^9 
-  1 ≤ p ≤ N 
-  1 ≤ R ≤ N 

-----Subtasks-----
Subtask #1 (5 points) : 

-  1 ≤ N ≤ 10 
-  1 ≤ Q  ≤ 1000 
-  1 ≤ Fi ≤ 10 
-  1 ≤ f ≤ 10 

Subtask #2 (15 points) : 

-  1 ≤ N ≤ 1000 
-  1 ≤ Q  ≤ 100 
-  1 ≤ Fi ≤ 109 
-  1 ≤ f ≤ 1000 

Subtask #3 (80 points) : 

- original constraints

-----Example-----
Input:
5
1 2 3 4 5
3
2 1
1 3 10
2 2

Output:
1 120
5 50

-----Explanation-----
In the first query, Chef is going to visit cities 1, 2, 3, 4, 5 in order. At the end of the trip, his total enjoyment will be 1 * 2 * 3 * 4 * 5 = 120. First digit of enjoyment is 1 and 120 modulo 109 + 7 is 120.
In the third query, Chef is going to visit cities 1, 3, 5 in order. At the end of the trip, his total enjoyment will be 1 * 10 * 5 = 50.

Difficulty: UNKNOWN_DIFFICULTY

Solutions:
n = int(input())
a = list(map(int, input().split()))
q = int(input())
while q > 0:
	i = 1
	tot = a[0]
	b = list(map(int, input().split()))
	if b[0] == 1:
		a[b[1] - 1] = b[2]
	else:
		tot = a[0]
		while 1 + i * b[1] <= n:
			tot = tot * a[i * b[1]]
			i = i + 1
		m = str(tot)
		tot = tot % 1000000007
		print(int(m[0]), tot)
	q = q - 1


mod = 10 ** 9 + 7
n = eval(input())
arr = list(map(int, input().strip().split()))
for _ in range(eval(input())):
	q = list(map(int, input().strip().split()))
	if q[0] == 1:
		(p, f) = (q[1], q[2])
		arr[p - 1] = f
	else:
		r = q[1]
		ans = 1
		for i in range(0, n, r):
			ans *= arr[i]
		print(str(ans)[0], ans % mod)


n = int(input())
f = [int(x) for x in input().split()]
q = int(input())
while q != 0:
	q = q - 1
	query = [int(x) for x in input().split()]
	if query[0] == 1:
		f[query[1] - 1] = query[2]
		continue
	elif query[0] == 2:
		ans = f[0]
		if ans == 0:
			print('0 0')
			continue
		i = 1
		r = query[1]
		while i * r < n:
			ans = ans * f[i * r]
			i += 1
		print(str(ans)[0], ans % 1000000000)


import math

def solve(array, r):
	(i, res, tmp1, tmp2) = (0, 1, 1, 1)
	while i * r < len(array):
		res *= array[i * r]
		res %= 10 ** 9 + 7
		tmp1 = float(array[i * r]) / 10 ** int(math.log(array[i * r], 10))
		tmp2 *= tmp1
		tmp2 = float(tmp2) / 10 ** int(math.log(tmp2, 10))
		i += 1
	first_digit = int(tmp2 // 10 ** int(math.log(tmp2, 10)))
	return ' '.join((str(first_digit), str(res)))

def frjump():
	N = int(input())
	friendliness = list(map(int, input().split()))
	Q = int(input())
	for _ in range(Q):
		query = list(map(int, input().split()))
		if query[0] == 1:
			friendliness[query[1] - 1] = query[2]
		else:
			(types, R) = query
			print(solve(friendliness, R))

def __starting_point():
	frjump()
__starting_point()


from math import *

def karatsuba(x, y):
	tmp = 10
	if x < 10 or y < 10:
		return x * y
	m = max(int(log10(x) + 1), int(log10(y) + 1))
	if m % 2 != 0:
		m -= 1
	m_2 = int(m / 2)
	(a, b) = divmod(x, tmp ** m_2)
	(c, d) = divmod(y, tmp ** m_2)
	ac = karatsuba(a, c)
	bd = karatsuba(b, d)
	ad_bc = karatsuba(a + b, c + d) - ac - bd
	return ac * 10 ** m + bd + ad_bc * 10 ** m_2

def solve(array, r):
	i = 0
	res = 1
	while i * r < len(array):
		res = karatsuba(res, array[i * r])
		i += 1
	return ' '.join((str(res)[0], str(res % (10 ** 9 + 7))))

def frjump():
	N = int(input())
	friendliness = list(map(int, input().split()))
	Q = int(input())
	for _ in range(Q):
		query = list(map(int, input().split()))
		if query[0] == 1:
			friendliness[query[1] - 1] = query[2]
		else:
			(types, R) = query
			print(solve(friendliness, R))

def __starting_point():
	frjump()
__starting_point()


n = int(input())
L = list(map(int, input().split()))
q = int(input())
F = [0 for i in range(100055)]
i = 1
for t in L:
	F[i] = t
	i += 1
while q > 0:
	q -= 1
	l1 = list(map(int, input().split()))
	if l1[0] == 1:
		F[l1[1]] = l1[2]
	else:
		r = l1[1]
		enjoy = F[1]
		k = 1
		while 1:
			if 1 + k * r > n:
				break
			enjoy = enjoy * F[1 + k * r]
			k += 1
		temp = enjoy
		while 1:
			if temp // 10 == 0:
				print(temp, end=' ')
				break
			temp = temp // 10
		print(enjoy % 1000000007)


M = 10 ** 9 + 7
n = int(input())
f = list(map(int, input().split()))
q = int(input())
for i in range(q):
	query = input().split()
	if query[0] == '1':
		f[int(query[1]) - 1] = int(query[2])
	else:
		r = int(query[1])
		k = 0
		ans = 1
		while k < n:
			ans *= f[k]
			k += r
		print(str(ans)[0], ans % M)