This page is still under construction.

Parts of this page are still being built. What you see may change.

Range product queries

Interview

Time limit1sMemory limit256 MB

Summary
Answer range product queries modulo 1,000,000,007 on a sequence with point updates.
Level

Medium4 of 10

Topics
Segment tree
Solved
No attempts yet

Problem

You are given a sequence of NN numbers. Elements of the sequence change often, and between those changes you have to compute the product of some range.

For example, take the sequence 1, 2, 3, 4, 5. Change the third number to 6 and ask for the product from the second number to the fifth, and the answer is 240. Then change the fifth number to 2 and ask for the product from the third number to the fifth, and the answer is 48.

Given changes and range product queries mixed together, write a program that computes the product for each query.

Input

The first line contains the count of numbers NN (1≤N≤1,000,0001 \le N \le 1{,}000{,}000), the number of changes MM (1≤M≤10,0001 \le M \le 10{,}000), and the number of range product queries KK (1≤K≤10,0001 \le K \le 10{,}000), separated by spaces.

The next NN lines contain the elements of the sequence in order, one per line.

The following M+KM + K lines each contain three integers aa, bb, and cc. If aa is 1, change the bb-th number to cc. If aa is 2, compute the product from the bb-th number to the cc-th number. On a line where aa is 2, b≤cb \le c holds.

Every number in the input is an integer between 0 and 1,000,000, inclusive.

Output

Print one line for each product query, in the order the queries are given, for a total of KK lines. Each line holds the product of that range modulo 1,000,000,007.

Examples2

  1. Example 1

    Input
    5 2 2
    1
    2
    3
    4
    5
    1 3 6
    2 2 5
    1 5 2
    2 3 5
    
    Expected output
    240
    48
    
  2. Example 2

    Input
    5 2 2
    1
    2
    3
    4
    5
    1 3 0
    2 2 5
    1 3 6
    2 2 5
    
    Expected output
    0
    240