Ensure that you are logged in and have the required permissions to access the test.
Doraemon has an array A of N positive integers. He asks Q queries on this array. Each queries are of type : L, R, X, K. For query P and Q are generated from L, R and answer for query (suppose previous_query_answer) as following pseudocode:
P = (L + previous_query_answer) % N + 1
Q = (R + previous_query_answer) % N + 1
if ( ) swap(P, Q)
For 1st query previous_query_answer = 0.
Answer to the query is count of all elements Y in subarray such that . Show him that you are a pro by answering the queries.
First line of input contains integer N - size of array. Next line contains N integers of array. Next line contains integer Q - number of queries. Next Q line contains queries of type : L R X K as mentioned in problem statement.
For each query print the required answer per line.
1 <= N <=
1 <= Q <=
1 <= <=
1 <= L <= R <=
0 <= <=