This page is still under construction.

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

Polynomial and Easy Queries

Time limit2sMemory limit256 MB

Summary
Maintain an array under range applications of f(x)=2x^2-1 and g(x)=4x^3-3x, and answer point queries modulo 100003.
Level

Hard9 of 10

Topics
Math, Segment tree, Number theory, Combinatorics
Solved
No attempts yet

Problem

You are given a sequence AA of length NN. Write a program that processes the following three kinds of queries on this sequence.

  • 11 ll rr: replace every AiA_i with f(Ai)f(A_i) for all l≤i≤rl \le i \le r.
  • 22 ll rr: replace every AiA_i with g(Ai)g(A_i) for all l≤i≤rl \le i \le r.
  • 33 xx: print AxA_x. The answer can grow very large, so print it modulo 100 003100\,003.

Here f(x)=2x2−1f(x)=2x^2 -1 and g(x)=4x3−3xg(x) = 4x^3 - 3x.

Input

The first line contains the length of the sequence NN and the number of queries QQ.

The second line contains the initial state of the sequence, A1,A2,⋯ ,ANA_1, A_2, \cdots, A_N.

Each of the next QQ lines contains one query in the form above (tt ll rr or tt xx), in order.

Output

For every query of type 3, print its answer on a line.

Constraints

  • 1≤N≤5×1051 \le N \le 5 \times 10^5
  • 1≤Q≤5×1051 \le Q \le 5 \times 10^5
  • 1≤Ai≤1051 \le A_i \le 10^5
  • For every query, 1≤t≤31 \le t \le 3, 1≤l≤r≤N1 \le l \le r \le N, 1≤x≤N1 \le x \le N
  • At least one query of type 3 is given.

Examples1

  1. Example 1

    Input
    3 3
    1 2 3
    1 1 3
    2 1 3
    3 2
    
    Expected output
    1351