Digit DP
시간 제한5초메모리 제한2048 MB
부분집합 합으로 정의된 0부터 2^n-1까지의 배열에서 구간 덧셈과 세 원소 곱의 합을 구하는 구간 질의를 처리한다.
문제
There are machines in a factory, numbered from to . The -th machine consumes units of power. The factory uses a system called Digit Dynamic Powering (Digit DP) to control the power the machines consume.
Initially, an array is given. Then the system would set the initial to , where is the set of bits in the binary representation of .
After that, there may be some modifications, each modification would be adding a certain value to the power of some machines that form an interval. Formally speaking, you would be given three integers , , , meaning that the power consumed by each of the machines numbered between and (inclusively) should increase by . The endpoints of the intervals would be given as -digit binary strings.
When some three distinct machines are used to produce a product, the product's price should always be the product of the 's of those machines.
During these modifications, the manager may ask some questions about some intervals. What is the sum of the prices if we try every possible combination of three distinct machines in the interval to produce a product?
Formally speaking, you would be given two integers , , meaning that you should report the sum of the products of all triples satisfying . As the answer may be rather large, find it modulo . The endpoints of the intervals would also be given as -digit binary strings.
입력
The first line contains two integers and (; ).
The second line contains the integer array ().
The next lines contain queries. On each line, the first integer indicates the type of the query.
If , three integers , , follow (, ).
If , two integers , follow ().
Note that and are given in -bit binary string format, and the leftmost bit is the highest bit.
출력
For each query of type , print a line with a single integer: the answer modulo .