Five
시간 제한0.7초메모리 제한1024 MB
배열에 구간 덧셈을 하고, 계수 5,4,3,2,1인 선형 점화식 x_k의 구간 합을 구한다.
문제
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 to . So we will focus on the next number, , and hope it does not follow the unfortunate fate of its predecessors.
Consider the following sequence in the positive and negative indices:
- for each integer .
Note that equality uniquely defines both the positive and the negative indices (e.g. , , and , , )
You are given an array of numbers . Write a program five that supports types of events:
- Query with parameters , . We want to find the value . Since it can get very large, print the answer modulo .
- Update with parameters , , Then the new value of becomes equal to for every .
입력
The first line of the standard input contains the numbers and . The next line contains integers . Each of the following lines contains natural numbers , , .
- If , then the line is a Query.
- If , then the line is an Update and contains a further integer .
출력
For each Query, print on a new line the answer for that query.