SOLVE

LATER

Distinct Digits II

/

Andi and Bob are the best friends of each other.They both are good programmers as well,They like to do programming together so that if one finds any difficulty other can help.But these days Andi is quite busy as his exams are on the way . So, Bob has to do programming alone.while practising on HackerEarth Bob encounters an interesting problem which he was unable to solve efficiently.So, he asked for Andi's help.

Problem as stated by Bob :

Given an array of N elements and Q queries need to be processed over this array.A query can be any of the following three types.

Type ADD: u v

Type MUL: u v

Type REP: u v

Type MAX: l r

Type MIN: l r

**Explanation**:

for query Type ADD: replace the uth element of the array with (uth element+v)%MOD;

for query Type MUL: replace the uth element of the array with (uth element *v)%MOD;

for query Type REP: replace uth element of the array with v%MOD

for query Type MAX: count the number of numbers which have MAXIMUM distinct digits between l to r, both inclusive

for query Type MIN: count the number of numbers which have MINIMUM distinct digits between l to r, both inclusive

Andi likes the problem very much and wants to solve it.But being super busy with exams, he has no time to help Bob. But he can’t let Bob feel helpless with any problem. So can you please help Bob and save their friendship?

**note**: Assume MOD=10^9+7.

I check even my code is giving WA on sample test case so please do submit your code to check the result and please ensure output format should be same as mentioned in the problem statement . print a new line after each query of type MIN or MAX.

**INPUT:**

First line of the input contains a single integer N denoting the number of elements in the array.Next line of input contains N space seperated integers.Third line of input contains a single interger Q denoting the number of queries to be processed over the array.Next Q lines of input contain Q queries (one query per line).

**OUTPUT**:

for each query of type MIN and MAX print two space seperated integers number of distinct digits and number of such numbers.

**CONSTRAINT**:

1<=Q,N<=10^5

1<=A[i]<=10^9

1<=v<=10^9

1<=u,l,r<=N

Time Limit:
2.0 sec(s)
for each input file.

Memory Limit:
256 MB

Source Limit:
1024 KB

Initializing Code Editor...