Another Boring Problem

Time limit: 0.5s Memory limit: 256MB Input: Output:

You are given an array aa of length nn. You need to process qq queries. Each query is one of the following two types:

  1. xx - What is the value of axa_x modulo 109+710^9+7?
  2. x y b cx \ y \ b \ c - For every ii in the range [x,yx, y], aia_i becomes max(ai,bica_i, b \cdot i^c)

Input

The first line of input contains the integer nn, the length of the array.

The second line of the input contains nn integers, the ii-th being aia_i

The third line of the input contains an integer qq, the number of queries.

Each of the following qq lines contains a query of one of two aforementioned types.

Output

The output will contain the answers to queries of type 11 on the order they appear in the input.

Constraints

  • 1x,yn1051 \leq x, y \leq n \leq 10^5
  • 1ai,b,c1051 \leq a_i, b, c \leq 10^5
  • 1q21051 \leq q \leq 2 \cdot 10^5
  • For tests worth 55 points, every number in the input is smaller than or equal to 1010, except for qq
  • For tests worth 2525 more points, n103n \leq 10^3; q105q \leq 10^5
  • For tests worth 3030 more points, n5104n \leq 5 \cdot 10^4; q105q \leq 10^5
  • The scores obtained now may be different compared to the ones from the original contest

Example

stdin

10
5 3 7 8 3 9 10 10 1 2
15
1 7
2 1 5 3 3
1 5
1 4
1 1
2 6 10 2 2
1 6
1 7
1 10
2 1 10 10 10
1 1
1 2
1 10
1 7
1 3

stdout

10
375
192
5
72
98
200
10
10240
999999307
824752476
590490

Log in or sign up to be able to send submissions!