Five

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

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=0x_0 = 0
  • x1=1x_1 = 1
  • x2=2x_2 = 2
  • x3=3x_3 = 3
  • x4=4x_4 = 4
  • xk+5=5β‹…xk+4+4β‹…xk+3+3β‹…xk+2+2β‹…xk+1+xkx_{k+5} = 5 \cdot x_{k+4} + 4 \cdot x_{k+3} + 3 \cdot x_{k+2} + 2 \cdot x_{k+1} + x_{k} for each integer kk.

Note that equality uniquely defines both the positive and negative indices (e.g. x5=40x_5 = 40, x6=230x_6 = 230, ... and xβˆ’1=βˆ’22x_{-1} = -22, xβˆ’2=33x_{-2} = 33, ...)

Task

You are given an array of nn numbers a1,a2,...,ana_1, a_2, ..., a_n. Write a program that supports 2 types of events:

  • Query with parameters l,rl, r. We want to find the value xal+xal+1+...+xar=βˆ‘i=lrxaix_{a_{l}} + x_{a_{l + 1}} + ... + x_{a_{r}} = \sum_{i = l}^{r} x_{a_{i}}. Since it can get very large, print the answer modulo M=108+543M = 10^8 + 543.
  • Update with parameters l,r,valuel, r, value. Then the new value of aia_i becomes equal to ai+valuea_i+value for every l≀i≀rl \leq i \leq r.

Input data

The first line of the standard input contains the numbers nn and qq.
The next line contains nn integers a1,a2,…,ana_1, a_2, …, a_n. Each of the following qq lines contains 3 natural numbers type,l,rtype, l, r.

If type=1type = 1, then the line is a Query.
If type=2type = 2, then the line is an Update and contains a further integer valuevalue.

Output data

For each Query, print on a new line the answer for that query.

Constraints and clarifications

  • 1≀n≀100Β 0001 \leq n \leq 100\ 000
  • 1≀q≀200Β 0001 \leq q \leq 200\ 000
  • 1≀l≀r≀n1 \leq l \leq r \leq n
  • βˆ’M<ai,value<M-M < a_i, value < M
# Score Constraints
1 5 0≀ai≀1060 \leq a_i \leq 10^6 and only Query
2 19 0≀ai,value0 \leq a_i, value and l=rl = r
3 19 0≀ai,value0 \leq a_i, value and q≀20Β 000q \leq 20\ 000
4 19 q≀20Β 000q \leq 20\ 000
5 19 q≀100Β 000q \leq 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=1a_1 = 1 and xa1=1x_{a_1} = 1. After the first Update a1=βˆ’1a_1 = -1 and xa1=βˆ’22x_{a_1} = -22. After the second Update a1=7a_1 = 7 and xa1=1330x_{a_1} = 1330.

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