AlgoUniversity
  • Go Back
Discussion
Largest Power Summation :

Author

Yash Sahijwani

Difficulty Level : Medium

Submissions : 39

Asked In : Infosys

Marks :10

: 0 | : 0

Anwar has an array $$$A$$$ consisting of $$$N$$$ integers on which he performs $$$M$$$ operations.

In the $$$j_{th}$$$ operation he will perform one of the following tasks:

  • If T$$$_{j}$$$=1, then add $$$F(A_{i})$$$ to $$$A_{i}$$$ for each $$$i$$$ in the interval $$$[L_{j},R_{j}]$$$, where $$$(1 \leq L_{j} \leq R_{j} \leq N)$$$
  • If T$$$_{j}$$$=2, then do all operations of the first type from the $$$L_{j}$$$ operation to the $$$R_{j}$$$ operation again in the same order, where $$$(1 \leq L_{j} \leq R_{j} \leq N)$$$.

$$$F(x)$$$ is defined as the largest power of 2 that divides x. For example, $$$F(4)=4, F(5)=1$$$.

Find the final values in $$$A$$$ after performing all operations. Since the answer may be very large return the elements of $$$A$$$ modulo $$$10^9+7$$$.

Input

The first line of input consists of a single integer $$$n$$$ $$$(1 \leq n \leq 10^5)$$$ $$$-$$$ the total number of elements in the array $$$A$$$. The second line consists of $$$n$$$ space separated integers, the elements of the array $$$A$$$. The third line of input consists of a single integer $$$m$$$ $$$(0 \leq m \leq 10^5)$$$ $$$-$$$ the total number of queries. Each of the next $$$m$$$ lines consist of 3 space separated integers, which represent the queries. The format of each query is $$$type \; l \; r$$$, where $$$type$$$ denotes the type of the query and $$$l$$$ and $$$r$$$ denote the interval for the query.

Output

The output should consist of $$$n$$$ space separated integers $$$-$$$ the final elements of the array $$$A$$$.

Example

Input
5
2 7 8 8 5
3
1 4 4
2 1 1
1 4 5
Output
2 7 8 64 6 

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.