Due to unforeseen circumstances, this task is not fifth. A recent survey by polling agency "Ko & co" found that no one likes the numbers from 1 to 4. So we will focus on the next number, 5, and hope it does not follow the unfortunate fate of its predecessors.
Consider the following sequence in the positive and negative indices:
- x0β=0
- x1β=1
- x2β=2
- x3β=3
- x4β=4
- xk+5β=5β
xk+4β+4β
xk+3β+3β
xk+2β+2β
xk+1β+xkβ for each integer k.
Note that equality uniquely defines both the positive and negative indices (e.g. x5β=40, x6β=230, ... and xβ1β=β22, xβ2β=33, ...)
Task
You are given an array of n numbers a1β,a2β,...,anβ. Write a program that supports 2 types of events:
- Query with parameters l,r. We want to find the value xalββ+xal+1ββ+...+xarββ=βi=lrβxaiββ. Since it can get very large, print the answer modulo M=108+543.
- Update with parameters l,r,value. Then the new value of aiβ becomes equal to aiβ+value for every lβ€iβ€r.
The first line of the standard input contains the numbers n and q.
The next line contains n integers a1β,a2β,β¦,anβ. Each of the following q lines contains 3 natural numbers type,l,r.
If type=1, then the line is a Query.
If type=2, then the line is an Update and contains a further integer value.
Output data
For each Query, print on a new line the answer for that query.
Constraints and clarifications
- 1β€nβ€100Β 000
- 1β€qβ€200Β 000
- 1β€lβ€rβ€n
- βM<aiβ,value<M
# |
Score |
Constraints |
1 |
5 |
0β€aiββ€106 and only Query |
2 |
19 |
0β€aiβ,value and l=r |
3 |
19 |
0β€aiβ,value and qβ€20Β 000 |
4 |
19 |
qβ€20Β 000 |
5 |
19 |
qβ€100Β 000 |
6 |
19 |
No additional constraints |
Example
stdin
1 5
1
1 1 1
2 1 1 -2
1 1 1
2 1 1 8
1 1 1
stdout
1
100000521
1330
Explanation
At the start a1β=1 and xa1ββ=1. After the first Update a1β=β1 and xa1ββ=β22. After the second Update a1β=7 and xa1ββ=1330.